Last active 1710139911

nextcloud config

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