Skip to content

Commit a554746

Browse files
committed
fix(nginx): sync with nginx-admin docu
1 parent 8dd1b48 commit a554746

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

charts/nextcloud/files/nginx.config.tpl

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
# Version 2024-07-17
2+
13
upstream php-handler {
24
server 127.0.0.1:9000;
35
}
46

7+
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
8+
map $arg_v $asset_immutable {
9+
"" "";
10+
default ", immutable";
11+
}
12+
513
server {
614
{{- if and (has "IPv4" .Values.nginx.ipFamilies) (has "IPv6" .Values.nginx.ipFamilies) }}
715
# Both IPv4 and IPv6 are enabled
@@ -14,6 +22,12 @@ server {
1422
listen {{ .Values.nginx.containerPort }};
1523
{{- end }}
1624

25+
# Path to the root of your installation
26+
root /var/www/html;
27+
28+
# Prevent nginx HTTP Server Detection
29+
server_tokens off;
30+
1731
# HSTS settings
1832
# WARNING: Only add the preload option once you read about
1933
# the consequences in https://hstspreload.org/. This option
@@ -26,8 +40,9 @@ server {
2640
{{- end }}
2741
{{- end }}
2842

29-
# set max upload size
30-
client_max_body_size 10G;
43+
# set max upload size and increase upload timeout:
44+
client_max_body_size 512M;
45+
client_body_timeout 300s;
3146
fastcgi_buffers 64 4K;
3247

3348
# Enable gzip but do not remove ETag headers
@@ -36,27 +51,30 @@ server {
3651
gzip_comp_level 4;
3752
gzip_min_length 256;
3853
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
39-
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;
54+
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;
4055

4156
# Pagespeed is not supported by Nextcloud, so if your server is built
4257
# with the `ngx_pagespeed` module, uncomment this line to disable it.
4358
#pagespeed off;
4459

60+
# The settings allows you to optimize the HTTP2 bandwidth.
61+
# See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
62+
# for tuning hints
63+
client_body_buffer_size 512k;
64+
4565
# Remove X-Powered-By, which is an information leak
4666
fastcgi_hide_header X-Powered-By;
4767

48-
# Add .mjs as a file extension for javascript
68+
# Set .mjs and .wasm MIME types
4969
# Either include it in the default mime.types list
50-
# or include you can include that list explicitly and add the file extension
70+
# and include that list explicitly or add the file extension
5171
# only for Nextcloud like below:
5272
include mime.types;
5373
types {
5474
text/javascript js mjs;
75+
application/wasm wasm;
5576
}
5677

57-
# Path to the root of your installation
58-
root /var/www/html;
59-
6078
# Specify how to handle directories -- specifying `/index.php$request_uri`
6179
# here as the fallback means that Nginx always exhibits the desired behaviour
6280
# when a client requests a path that corresponds to a directory that exists
@@ -91,10 +109,10 @@ server {
91109
92110
location = /.well-known/carddav { return 301 /remote.php/dav/; }
93111
location = /.well-known/caldav { return 301 /remote.php/dav/; }
94-
# Anything else is dynamically handled by Nextcloud
95-
location ^~ /.well-known { return 301 /index.php$uri; }
96112

97-
try_files $uri $uri/ =404;
113+
# Let Nextcloud's API for `/.well-known` URIs handle all other
114+
# requests by passing them to the front-end controller.
115+
return 301 /index.php$request_uri;
98116
}
99117

100118
# Rules borrowed from `.htaccess` to hide certain paths from clients
@@ -106,8 +124,8 @@ server {
106124
# then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
107125
# to the URI, resulting in a HTTP 500 error response.
108126
location ~ \.php(?:$|/) {
109-
# Required for legacy support
110-
rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;
127+
# Required for legacy support
128+
rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;
111129
112130
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
113131
set $path_info $fastcgi_path_info;
@@ -117,28 +135,35 @@ server {
117135
include fastcgi_params;
118136
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
119137
fastcgi_param PATH_INFO $path_info;
120-
#fastcgi_param HTTPS on;
138+
fastcgi_param HTTPS on;
121139
122140
fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
123141
fastcgi_param front_controller_active true; # Enable pretty urls
124142
fastcgi_pass php-handler;
125143
126144
fastcgi_intercept_errors on;
127145
fastcgi_request_buffering off;
146+
147+
fastcgi_max_temp_file_size 0;
128148
}
129149

130-
location ~ \.(?:css|js|svg|gif)$ {
150+
location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac)$ {
131151
try_files $uri /index.php$request_uri;
132152
expires 6M; # Cache-Control policy borrowed from `.htaccess`
133153
access_log off; # Optional: Don't log access to assets
134154
}
135155
136-
location ~ \.woff2?$ {
156+
location ~ \.(otf|woff2?)$ {
137157
try_files $uri /index.php$request_uri;
138158
expires 7d; # Cache-Control policy borrowed from `.htaccess`
139159
access_log off; # Optional: Don't log access to assets
140160
}
141161

162+
# Rule borrowed from `.htaccess`
163+
location /remote {
164+
return 301 /remote.php$request_uri;
165+
}
166+
142167
location / {
143168
try_files $uri $uri/ /index.php$request_uri;
144169
}

charts/nextcloud/values.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ nginx:
347347
"Strict-Transport-Security": ""
348348
"Referrer-Policy": "no-referrer"
349349
"X-Content-Type-Options": "nosniff"
350-
"X-Download-Options": "noopen"
351350
"X-Frame-Options": "SAMEORIGIN"
352351
"X-Permitted-Cross-Domain-Policies": "none"
353352
"X-Robots-Tag": "noindex, nofollow"

0 commit comments

Comments
 (0)