Skip to content

Commit c1ee467

Browse files
authored
Update Nginx configuration for Nextcloud
1 parent 8dfc2fe commit c1ee467

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

.docker/web/nextcloud.conf

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
upstream php-handler {
22
server app:9000;
3+
#server unix:/run/php/php8.2-fpm.sock;
34
}
45

56
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
@@ -11,18 +12,17 @@ map $arg_v $asset_immutable {
1112
include /etc/nginx/mime.types;
1213
default_type application/octet-stream;
1314

14-
sendfile on;
15-
#tcp_nopush on;
15+
sendfile on;
16+
keepalive_timeout 65;
1617

17-
keepalive_timeout 65;
18-
19-
set_real_ip_from 10.0.0.0/8;
20-
set_real_ip_from 172.16.0.0/12;
21-
set_real_ip_from 192.168.0.0/16;
22-
real_ip_header X-Real-IP;
18+
set_real_ip_from 10.0.0.0/8;
19+
set_real_ip_from 172.16.0.0/12;
20+
set_real_ip_from 192.168.0.0/16;
21+
real_ip_header X-Real-IP;
2322

2423
server {
2524
listen 80;
25+
listen [::]:80;
2626
include /etc/nginx/conf.d/includes/*.conf;
2727

2828
# Path to the root of your installation
@@ -44,6 +44,13 @@ server {
4444
client_body_timeout 300s;
4545
fastcgi_buffers 64 4K;
4646

47+
# Proxy and client response timeouts
48+
# Uncomment and increase these if facing timeout errors during large file uploads
49+
#proxy_connect_timeout 60s;
50+
#proxy_send_timeout 60s;
51+
#proxy_read_timeout 60s;
52+
#send_timeout 60s;
53+
4754
# Enable gzip but do not remove ETag headers
4855
gzip on;
4956
gzip_vary on;
@@ -78,6 +85,7 @@ server {
7885
include mime.types;
7986
types {
8087
text/javascript mjs;
88+
application/wasm wasm;
8189
}
8290

8391
# Specify how to handle directories -- specifying `/index.php$request_uri`
@@ -151,14 +159,19 @@ server {
151159
fastcgi_pass php-handler;
152160

153161
fastcgi_intercept_errors on;
154-
fastcgi_request_buffering off;
162+
fastcgi_request_buffering on; # Required as PHP-FPM does not support chunked transfer encoding and requires a valid ContentLength header.
163+
164+
# PHP-FPM 504 response timeouts
165+
# Uncomment and increase these if facing timeout errors during large file uploads
166+
fastcgi_read_timeout 3600s;
167+
#fastcgi_send_timeout 60s;
168+
#fastcgi_connect_timeout 60s;
155169

156170
fastcgi_max_temp_file_size 0;
157-
fastcgi_read_timeout 3600;
158171
}
159172

160173
# Serve static files
161-
location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
174+
location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mp4|webm)$ {
162175
try_files $uri /index.php$request_uri;
163176
# HTTP response headers borrowed from Nextcloud `.htaccess`
164177
add_header Cache-Control "public, max-age=15778463$asset_immutable";
@@ -167,11 +180,10 @@ server {
167180
add_header X-Frame-Options "SAMEORIGIN" always;
168181
add_header X-Permitted-Cross-Domain-Policies "none" always;
169182
add_header X-Robots-Tag "noindex, nofollow" always;
170-
add_header X-XSS-Protection "1; mode=block" always;
171183
access_log off; # Optional: Don't log access to assets
172184
}
173185

174-
location ~ \.woff2?$ {
186+
location ~ \.(otf|woff2?)$ {
175187
try_files $uri /index.php$request_uri;
176188
expires 7d; # Cache-Control policy borrowed from `.htaccess`
177189
access_log off; # Optional: Don't log access to assets

0 commit comments

Comments
 (0)