@@ -3,14 +3,12 @@ worker_processes auto;
33error_log /var/log/nginx/error.log warn;
44pid /var/run/nginx.pid ;
55
6-
76events {
87 worker_connections 1024 ;
98}
109
1110http {
1211 disable_symlinks off;
13- # Prevent nginx HTTP Server Detection
1412 server_tokens off;
1513
1614 include /etc/nginx/mime.types ;
@@ -23,181 +21,18 @@ http {
2321 access_log /var/log/nginx/access.log main;
2422
2523 sendfile on;
26- #tcp_nopush on;
27-
2824 keepalive_timeout 65 ;
2925
3026 set_real_ip_from 10.0.0.0 /8;
3127 set_real_ip_from 172.16.0.0 /12 ;
3228 set_real_ip_from 192.168.0.0 /16 ;
3329 real_ip_header X-Real-IP;
3430
35- #gzip on;
36-
3731 upstream php-handler {
3832 server nextcloud:9000 ;
3933 }
4034
41- server {
42- listen 80 ;
43- include /etc/nginx/conf.d/includes/*.conf;
44-
45- # Add headers to serve security related headers
46- # Before enabling Strict-Transport-Security headers please read into this
47- # topic first.
48- add_header Strict-Transport-Security "max-age=15552000; includeSubDomains; preload;" always;
49-
50- # set max upload size
51- client_max_body_size 20G ;
52- fastcgi_buffers 64 4K ;
53-
54- # Enable gzip but do not remove ETag headers
55- gzip on;
56- gzip_vary on;
57- gzip_comp_level 4;
58- gzip_min_length 256 ;
59- gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
60- gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo +json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location .xloc text/vtt text/x-component text/x-cross-domain-policy;
61-
62- # Pagespeed is not supported by Nextcloud, so if your server is built
63- # with the `ngx_pagespeed` module, uncomment this line to disable it.
64- #pagespeed off;
65-
66- # The settings allows you to optimize the HTTP2 bandwidth.
67- # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
68- # for tuning hints
69- client_body_buffer_size 512k ;
70-
71- # HSTS settings
72- # WARNING: Only add the preload option once you read about
73- # the consequences in https://hstspreload.org/. This option
74- # will add the domain to a hardcoded list that is shipped
75- # in all major browsers and getting removed from this list
76- # could take several months.
77- #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
78-
79- # HTTP response headers borrowed from Nextcloud `.htaccess`
80- add_header Referrer-Policy "no-referrer" always;
81- add_header X-Content-Type-Options "nosniff" always;
82- add_header X-Download-Options "noopen" always;
83- add_header X-Frame-Options "SAMEORIGIN" always;
84- add_header X-Permitted-Cross-Domain-Policies "none" always;
85- add_header X-Robots-Tag "noindex,nofollow" always;
86- add_header X-XSS-Protection "1; mode=block" always;
87-
88- # Remove X-Powered-By, which is an information leak
89- fastcgi_hide_header X-Powered-By;
90-
91- # Path to the root of your installation
92- root /var/www/html;
93-
94- # Add .mjs as a file extension for javascript
95- # Either include it in the default mime.types list
96- # or include you can include that list explicitly and add the file extension
97- # only for Nextcloud like below:
98- include mime.types ;
99- types {
100- application/javascript js mjs;
101- }
102-
103- # Specify how to handle directories -- specifying `/index.php$request_uri`
104- # here as the fallback means that Nginx always exhibits the desired behaviour
105- # when a client requests a path that corresponds to a directory that exists
106- # on the server. In particular, if that directory contains an index.php file,
107- # that file is correctly served; if it doesn't, then the request is passed to
108- # the front-end controller. This consistent behaviour means that we don't need
109- # to specify custom rules for certain paths (e.g. images and other assets,
110- # `/updater`, `/ocs-provider`), and thus
111- # `try_files $uri $uri/ /index.php$request_uri`
112- # always provides the desired behaviour.
113- index index .php index .html /index .php$request_uri ;
114-
115- # Rule borrowed from `.htaccess` to handle Microsoft DAV clients
116- location = / {
117- if ( $http_user_agent ~ ^DavClnt ) {
118- return 302 /remote.php/webdav/$is_args$args ;
119- }
120- }
121-
122- location = /robots.txt {
123- allow all;
124- log_not_found off;
125- access_log off;
126- }
127-
128- # Make a regex exception for `/.well-known` so that clients can still
129- # access it despite the existence of the regex rule
130- # `location ~ /(\.|autotest|...)` which would otherwise handle requests
131- # for `/.well-known`.
132- location ^~ /.well-known {
133- # The rules in this block are an adaptation of the rules
134- # in `.htaccess` that concern `/.well-known`.
135-
136- location = /.well-known/carddav { return 301 http ://$host /remote.php/dav/; }
137- location = /.well-known/caldav { return 301 http ://$host /remote.php/dav/; }
138-
139- location /.well-known/acme-challenge { try_files $uri $uri / =404 ; }
140- location /.well-known/pki-validation { try_files $uri $uri / =404 ; }
141-
142- # Let Nextcloud's API for `/.well-known` URIs handle all other
143- # requests by passing them to the front-end controller.
144- return 301 /index .php$request_uri ;
145- }
146-
147- # Rules borrowed from `.htaccess` to hide certain paths from clients
148- location ~ ^/( ?:build|tests|config|lib|3rdparty |templates|data)( ?:$|/) { return 404 ; }
149- location ~ ^/( ?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
150-
151- # Ensure this block, which passes PHP files to the PHP process, is above the blocks
152- # which handle static assets (as seen below). If this block is not declared first,
153- # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
154- # to the URI, resulting in a HTTP 500 error response.
155- location ~ \.php(?:$|/) {
156- # Required for legacy support
157- rewrite ^/( ?!index |remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode\/proxy) /index .php$request_uri ;
158-
159- fastcgi_split_path_info ^( .+?\.php)( \/.*|) $;
160- set $path_info $fastcgi_path_info ;
161- try_files $fastcgi_script_name =404 ;
162-
163- include fastcgi_params;
164- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name ;
165- fastcgi_param PATH_INFO $path_info ;
166-
167- fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
168- fastcgi_param front_controller_active true; # Enable pretty urls
169- fastcgi_pass php-handler;
170-
171- fastcgi_intercept_errors on;
172- fastcgi_request_buffering off;
173-
174- fastcgi_max_temp_file_size 0;
175- }
176-
177- # Serve static files
178- location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
179- try_files $uri /index .php$request_uri ;
180- add_header Cache-Control "public, max-age=15778463" ;
181- access_log off; # Optional: Don't log access to assets
182-
183- location ~ \.wasm$ {
184- default_type application/wasm;
185- }
186- }
187-
188- location ~ \.woff2?$ {
189- try_files $uri /index .php$request_uri ;
190- expires 7d ; # Cache-Control policy borrowed from `.htaccess`
191- access_log off; # Optional: Don't log access to assets
192- }
193-
194- # Rule borrowed from `.htaccess`
195- location /remote {
196- return 301 /remote.php$request_uri ;
197- }
198-
199- location / {
200- try_files $uri $uri / /index .php$request_uri ;
201- }
202- }
203- }
35+ # Load HTTP and HTTPS server configurations
36+ include /etc/nginx/conf.d/http .conf;
37+ include /etc/nginx/conf.d/https.conf;
38+ }
0 commit comments