|
1 | | -worker_processes auto; |
2 | | - |
3 | | -error_log /var/log/nginx/error.log warn; |
4 | | -pid /tmp/nginx.pid; |
5 | | - |
6 | | - |
7 | | -events { |
8 | | - worker_connections 1024; |
| 1 | + upstream php-handler { |
| 2 | + server 127.0.0.1:9000; |
9 | 3 | } |
10 | 4 |
|
11 | | - |
12 | | -http { |
13 | | - include /etc/nginx/mime.types; |
14 | | - default_type application/octet-stream; |
15 | | - |
16 | | - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
17 | | - '$status $body_bytes_sent "$http_referer" ' |
18 | | - '"$http_user_agent" "$http_x_forwarded_for"'; |
19 | | - |
20 | | - access_log /var/log/nginx/access.log main; |
21 | | - |
22 | | - sendfile on; |
23 | | - #tcp_nopush on; |
24 | | - |
25 | | - keepalive_timeout 65; |
26 | | - |
27 | | - #gzip on; |
28 | | - |
29 | | - upstream php-handler { |
30 | | - server 127.0.0.1:9000; |
31 | | - } |
32 | | - |
33 | | - server { |
34 | | - listen {{ .Values.nginx.containerPort }}; |
35 | | - |
36 | | - # HSTS settings |
37 | | - # WARNING: Only add the preload option once you read about |
38 | | - # the consequences in https://hstspreload.org/. This option |
39 | | - # will add the domain to a hardcoded list that is shipped |
40 | | - # in all major browsers and getting removed from this list |
41 | | - # could take several months. |
42 | | - #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; |
43 | | - |
44 | | - # set max upload size |
45 | | - client_max_body_size 10G; |
46 | | - fastcgi_buffers 64 4K; |
47 | | - |
48 | | - # Enable gzip but do not remove ETag headers |
49 | | - gzip on; |
50 | | - gzip_vary on; |
51 | | - gzip_comp_level 4; |
52 | | - gzip_min_length 256; |
53 | | - gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; |
54 | | - gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject 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; |
55 | | - |
56 | | - # Pagespeed is not supported by Nextcloud, so if your server is built |
57 | | - # with the `ngx_pagespeed` module, uncomment this line to disable it. |
58 | | - #pagespeed off; |
59 | | - |
60 | | - # HTTP response headers borrowed from Nextcloud `.htaccess` |
61 | | - add_header Referrer-Policy "no-referrer" always; |
62 | | - add_header X-Content-Type-Options "nosniff" always; |
63 | | - add_header X-Download-Options "noopen" always; |
64 | | - add_header X-Frame-Options "SAMEORIGIN" always; |
65 | | - add_header X-Permitted-Cross-Domain-Policies "none" always; |
66 | | - add_header X-Robots-Tag "noindex, nofollow" always; |
67 | | - add_header X-XSS-Protection "1; mode=block" always; |
68 | | - |
69 | | - # Remove X-Powered-By, which is an information leak |
70 | | - fastcgi_hide_header X-Powered-By; |
71 | | - |
72 | | - # Path to the root of your installation |
73 | | - root /var/www/html; |
74 | | - |
75 | | - # Specify how to handle directories -- specifying `/index.php$request_uri` |
76 | | - # here as the fallback means that Nginx always exhibits the desired behaviour |
77 | | - # when a client requests a path that corresponds to a directory that exists |
78 | | - # on the server. In particular, if that directory contains an index.php file, |
79 | | - # that file is correctly served; if it doesn't, then the request is passed to |
80 | | - # the front-end controller. This consistent behaviour means that we don't need |
81 | | - # to specify custom rules for certain paths (e.g. images and other assets, |
82 | | - # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus |
83 | | - # `try_files $uri $uri/ /index.php$request_uri` |
84 | | - # always provides the desired behaviour. |
85 | | - index index.php index.html /index.php$request_uri; |
86 | | - |
87 | | - # Rule borrowed from `.htaccess` to handle Microsoft DAV clients |
88 | | - location = / { |
89 | | - if ( $http_user_agent ~ ^DavClnt ) { |
90 | | - return 302 /remote.php/webdav/$is_args$args; |
91 | | - } |
| 5 | +server { |
| 6 | + listen {{ .Values.nginx.containerPort }}; |
| 7 | + |
| 8 | + # HSTS settings |
| 9 | + # WARNING: Only add the preload option once you read about |
| 10 | + # the consequences in https://hstspreload.org/. This option |
| 11 | + # will add the domain to a hardcoded list that is shipped |
| 12 | + # in all major browsers and getting removed from this list |
| 13 | + # could take several months. |
| 14 | + #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; |
| 15 | + |
| 16 | + # set max upload size |
| 17 | + client_max_body_size 10G; |
| 18 | + fastcgi_buffers 64 4K; |
| 19 | + |
| 20 | + # Enable gzip but do not remove ETag headers |
| 21 | + gzip on; |
| 22 | + gzip_vary on; |
| 23 | + gzip_comp_level 4; |
| 24 | + gzip_min_length 256; |
| 25 | + gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; |
| 26 | + gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject 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; |
| 27 | + |
| 28 | + # Pagespeed is not supported by Nextcloud, so if your server is built |
| 29 | + # with the `ngx_pagespeed` module, uncomment this line to disable it. |
| 30 | + #pagespeed off; |
| 31 | + |
| 32 | + # HTTP response headers borrowed from Nextcloud `.htaccess` |
| 33 | + add_header Referrer-Policy "no-referrer" always; |
| 34 | + add_header X-Content-Type-Options "nosniff" always; |
| 35 | + add_header X-Download-Options "noopen" always; |
| 36 | + add_header X-Frame-Options "SAMEORIGIN" always; |
| 37 | + add_header X-Permitted-Cross-Domain-Policies "none" always; |
| 38 | + add_header X-Robots-Tag "noindex, nofollow" always; |
| 39 | + add_header X-XSS-Protection "1; mode=block" always; |
| 40 | + |
| 41 | + # Remove X-Powered-By, which is an information leak |
| 42 | + fastcgi_hide_header X-Powered-By; |
| 43 | + |
| 44 | + # Path to the root of your installation |
| 45 | + root /var/www/html; |
| 46 | + |
| 47 | + # Specify how to handle directories -- specifying `/index.php$request_uri` |
| 48 | + # here as the fallback means that Nginx always exhibits the desired behaviour |
| 49 | + # when a client requests a path that corresponds to a directory that exists |
| 50 | + # on the server. In particular, if that directory contains an index.php file, |
| 51 | + # that file is correctly served; if it doesn't, then the request is passed to |
| 52 | + # the front-end controller. This consistent behaviour means that we don't need |
| 53 | + # to specify custom rules for certain paths (e.g. images and other assets, |
| 54 | + # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus |
| 55 | + # `try_files $uri $uri/ /index.php$request_uri` |
| 56 | + # always provides the desired behaviour. |
| 57 | + index index.php index.html /index.php$request_uri; |
| 58 | + |
| 59 | + # Rule borrowed from `.htaccess` to handle Microsoft DAV clients |
| 60 | + location = / { |
| 61 | + if ( $http_user_agent ~ ^DavClnt ) { |
| 62 | + return 302 /remote.php/webdav/$is_args$args; |
92 | 63 | } |
| 64 | + } |
93 | 65 |
|
94 | | - location = /robots.txt { |
95 | | - allow all; |
96 | | - log_not_found off; |
97 | | - access_log off; |
98 | | - } |
| 66 | + location = /robots.txt { |
| 67 | + allow all; |
| 68 | + log_not_found off; |
| 69 | + access_log off; |
| 70 | + } |
99 | 71 |
|
100 | | - # Make a regex exception for `/.well-known` so that clients can still |
101 | | - # access it despite the existence of the regex rule |
102 | | - # `location ~ /(\.|autotest|...)` which would otherwise handle requests |
103 | | - # for `/.well-known`. |
104 | | - location ^~ /.well-known { |
105 | | - # The following 6 rules are borrowed from `.htaccess` |
| 72 | + # Make a regex exception for `/.well-known` so that clients can still |
| 73 | + # access it despite the existence of the regex rule |
| 74 | + # `location ~ /(\.|autotest|...)` which would otherwise handle requests |
| 75 | + # for `/.well-known`. |
| 76 | + location ^~ /.well-known { |
| 77 | + # The following 6 rules are borrowed from `.htaccess` |
106 | 78 |
|
107 | | - location = /.well-known/carddav { return 301 /remote.php/dav/; } |
108 | | - location = /.well-known/caldav { return 301 /remote.php/dav/; } |
109 | | - # Anything else is dynamically handled by Nextcloud |
110 | | - location ^~ /.well-known { return 301 /index.php$uri; } |
| 79 | + location = /.well-known/carddav { return 301 /remote.php/dav/; } |
| 80 | + location = /.well-known/caldav { return 301 /remote.php/dav/; } |
| 81 | + # Anything else is dynamically handled by Nextcloud |
| 82 | + location ^~ /.well-known { return 301 /index.php$uri; } |
111 | 83 |
|
112 | | - try_files $uri $uri/ =404; |
113 | | - } |
| 84 | + try_files $uri $uri/ =404; |
| 85 | + } |
114 | 86 |
|
115 | | - # Rules borrowed from `.htaccess` to hide certain paths from clients |
116 | | - location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } |
117 | | - location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } |
| 87 | + # Rules borrowed from `.htaccess` to hide certain paths from clients |
| 88 | + location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } |
| 89 | + location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } |
118 | 90 |
|
119 | | - # Ensure this block, which passes PHP files to the PHP process, is above the blocks |
120 | | - # which handle static assets (as seen below). If this block is not declared first, |
121 | | - # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` |
122 | | - # to the URI, resulting in a HTTP 500 error response. |
123 | | - location ~ \.php(?:$|/) { |
124 | | - # Required for legacy support |
125 | | - rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri; |
| 91 | + # Ensure this block, which passes PHP files to the PHP process, is above the blocks |
| 92 | + # which handle static assets (as seen below). If this block is not declared first, |
| 93 | + # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` |
| 94 | + # to the URI, resulting in a HTTP 500 error response. |
| 95 | + location ~ \.php(?:$|/) { |
| 96 | + # Required for legacy support |
| 97 | + rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri; |
126 | 98 |
|
127 | | - fastcgi_split_path_info ^(.+?\.php)(/.*)$; |
128 | | - set $path_info $fastcgi_path_info; |
| 99 | + fastcgi_split_path_info ^(.+?\.php)(/.*)$; |
| 100 | + set $path_info $fastcgi_path_info; |
129 | 101 |
|
130 | | - try_files $fastcgi_script_name =404; |
| 102 | + try_files $fastcgi_script_name =404; |
131 | 103 |
|
132 | | - include fastcgi_params; |
133 | | - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
134 | | - fastcgi_param PATH_INFO $path_info; |
135 | | - #fastcgi_param HTTPS on; |
| 104 | + include fastcgi_params; |
| 105 | + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 106 | + fastcgi_param PATH_INFO $path_info; |
| 107 | + #fastcgi_param HTTPS on; |
136 | 108 |
|
137 | | - fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice |
138 | | - fastcgi_param front_controller_active true; # Enable pretty urls |
139 | | - fastcgi_pass php-handler; |
| 109 | + fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice |
| 110 | + fastcgi_param front_controller_active true; # Enable pretty urls |
| 111 | + fastcgi_pass php-handler; |
140 | 112 |
|
141 | | - fastcgi_intercept_errors on; |
142 | | - fastcgi_request_buffering off; |
143 | | - } |
| 113 | + fastcgi_intercept_errors on; |
| 114 | + fastcgi_request_buffering off; |
| 115 | + } |
144 | 116 |
|
145 | | - location ~ \.(?:css|js|svg|gif)$ { |
146 | | - try_files $uri /index.php$request_uri; |
147 | | - expires 6M; # Cache-Control policy borrowed from `.htaccess` |
148 | | - access_log off; # Optional: Don't log access to assets |
149 | | - } |
| 117 | + location ~ \.(?:css|js|svg|gif)$ { |
| 118 | + try_files $uri /index.php$request_uri; |
| 119 | + expires 6M; # Cache-Control policy borrowed from `.htaccess` |
| 120 | + access_log off; # Optional: Don't log access to assets |
| 121 | + } |
150 | 122 |
|
151 | | - location ~ \.woff2?$ { |
152 | | - try_files $uri /index.php$request_uri; |
153 | | - expires 7d; # Cache-Control policy borrowed from `.htaccess` |
154 | | - access_log off; # Optional: Don't log access to assets |
155 | | - } |
| 123 | + location ~ \.woff2?$ { |
| 124 | + try_files $uri /index.php$request_uri; |
| 125 | + expires 7d; # Cache-Control policy borrowed from `.htaccess` |
| 126 | + access_log off; # Optional: Don't log access to assets |
| 127 | + } |
156 | 128 |
|
157 | | - location / { |
158 | | - try_files $uri $uri/ /index.php$request_uri; |
159 | | - } |
| 129 | + location / { |
| 130 | + try_files $uri $uri/ /index.php$request_uri; |
160 | 131 | } |
161 | 132 | } |
0 commit comments