Skip to content

Commit 6cffe9a

Browse files
authored
Merge pull request #24 from raimund-schluessler/patch-1
2 parents 9468f74 + d7510da commit 6cffe9a

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

nextcloud.conf

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@ upstream php-handler {
33
#server unix:/var/run/php/php7.4-fpm.sock;
44
}
55

6+
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
7+
map $arg_v $asset_immutable {
8+
"" "";
9+
default "immutable";
10+
}
11+
12+
613
server {
714
listen 80;
815
listen [::]:80;
916

17+
# Prevent nginx HTTP Server Detection
18+
server_tokens off;
19+
1020
# Enforce HTTPS
1121
return 301 https://$server_name$request_uri;
1222
}
@@ -15,19 +25,25 @@ server {
1525
listen 443 ssl http2;
1626
listen [::]:443 ssl http2;
1727

28+
# Path to the root of your installation
29+
root /var/www/nextcloud;
30+
1831
# Use Mozilla's guidelines for SSL/TLS settings
1932
# https://mozilla.github.io/server-side-tls/ssl-config-generator/
2033
# NOTE: some settings below might be redundant
2134
ssl_certificate /etc/nginx/certs/cert.pem;
2235
ssl_certificate_key /etc/nginx/certs/key.pem;
2336

37+
# Prevent nginx HTTP Server Detection
38+
server_tokens off;
39+
2440
# HSTS settings
2541
# WARNING: Only add the preload option once you read about
2642
# the consequences in https://hstspreload.org/. This option
2743
# will add the domain to a hardcoded list that is shipped
2844
# in all major browsers and getting removed from this list
2945
# could take several months.
30-
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
46+
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;
3147

3248
# set max upload size and increase upload timeout:
3349
client_max_body_size 512M;
@@ -40,26 +56,37 @@ server {
4056
gzip_comp_level 4;
4157
gzip_min_length 256;
4258
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
43-
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/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;
59+
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;
4460

4561
# Pagespeed is not supported by Nextcloud, so if your server is built
4662
# with the `ngx_pagespeed` module, uncomment this line to disable it.
4763
#pagespeed off;
4864

65+
# The settings allows you to optimize the HTTP2 bandwitdth.
66+
# See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
67+
# for tunning hints
68+
client_body_buffer_size 512k;
69+
4970
# HTTP response headers borrowed from Nextcloud `.htaccess`
50-
add_header Referrer-Policy "no-referrer" always;
51-
add_header X-Content-Type-Options "nosniff" always;
52-
add_header X-Download-Options "noopen" always;
53-
add_header X-Frame-Options "SAMEORIGIN" always;
54-
add_header X-Permitted-Cross-Domain-Policies "none" always;
55-
add_header X-Robots-Tag "none" always;
56-
add_header X-XSS-Protection "1; mode=block" always;
71+
add_header Referrer-Policy "no-referrer" always;
72+
add_header X-Content-Type-Options "nosniff" always;
73+
add_header X-Download-Options "noopen" always;
74+
add_header X-Frame-Options "SAMEORIGIN" always;
75+
add_header X-Permitted-Cross-Domain-Policies "none" always;
76+
add_header X-Robots-Tag "noindex, nofollow" always;
77+
add_header X-XSS-Protection "1; mode=block" always;
5778

5879
# Remove X-Powered-By, which is an information leak
5980
fastcgi_hide_header X-Powered-By;
6081

61-
# Path to the root of your installation
62-
root /var/www/nextcloud;
82+
# Add .mjs as a file extension for javascript
83+
# Either include it in the default mime.types list
84+
# or include you can include that list explicitly and add the file extension
85+
# only for Nextcloud like below:
86+
include mime.types;
87+
types {
88+
text/javascript js mjs;
89+
}
6390

6491
# Specify how to handle directories -- specifying `/index.php$request_uri`
6592
# here as the fallback means that Nginx always exhibits the desired behaviour
@@ -137,9 +164,10 @@ server {
137164
fastcgi_max_temp_file_size 0;
138165
}
139166

140-
location ~ \.(?:css|js|svg|gif|png|jpg|ico|wasm|tflite|map)$ {
167+
# Serve static files
168+
location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map)$ {
141169
try_files $uri /index.php$request_uri;
142-
expires 6M; # Cache-Control policy borrowed from `.htaccess`
170+
add_header Cache-Control "public, max-age=15778463, $asset_immutable";
143171
access_log off; # Optional: Don't log access to assets
144172

145173
location ~ \.wasm$ {
@@ -161,4 +189,4 @@ server {
161189
location / {
162190
try_files $uri $uri/ /index.php$request_uri;
163191
}
164-
}
192+
}

0 commit comments

Comments
 (0)