blob: e143a7910e9d97166d95122b1824ae2ba8fe529e [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001map $http_x_forwarded_proto $client_req_scheme_nc {
2 default $scheme;
3 https https;
4}
5
6server {
7 include /etc/nginx/conf.d/listen_ssl.active;
8 include /etc/nginx/conf.d/listen_plain.active;
9 include /etc/nginx/mime.types;
10 charset utf-8;
11 override_charset on;
12
13 ssl_certificate /etc/ssl/mail/cert.pem;
14 ssl_certificate_key /etc/ssl/mail/key.pem;
15 ssl_protocols TLSv1.2 TLSv1.3;
16 ssl_prefer_server_ciphers on;
17 ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
18 ssl_ecdh_curve X25519:X448:secp384r1:secp256k1;
19 ssl_session_cache shared:SSL:50m;
20 ssl_session_timeout 1d;
21 ssl_session_tickets off;
22 add_header Referrer-Policy "no-referrer" always;
23 add_header X-Content-Type-Options "nosniff" always;
24 add_header X-Download-Options "noopen" always;
25 add_header X-Frame-Options "SAMEORIGIN" always;
26 add_header X-Permitted-Cross-Domain-Policies "none" always;
27 add_header X-Robots-Tag "none" always;
28 add_header X-XSS-Protection "1; mode=block" always;
29
30 fastcgi_hide_header X-Powered-By;
31
32 server_name NC_SUBD;
33
34 root /web/nextcloud/;
35
36 location = /robots.txt {
37 allow all;
38 log_not_found off;
39 access_log off;
40 }
41
42 location = /.well-known/carddav {
43 return 301 $client_req_scheme_nc://$host/remote.php/dav;
44 }
45
46 location = /.well-known/caldav {
47 return 301 $client_req_scheme_nc://$host/remote.php/dav;
48 }
49
50 location ^~ /.well-known/acme-challenge/ {
51 default_type "text/plain";
52 root /web;
53 }
54
55 fastcgi_buffers 64 4K;
56
57 gzip on;
58 gzip_vary on;
59 gzip_comp_level 4;
60 gzip_min_length 256;
61 gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
62 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;
63 set_real_ip_from fc00::/7;
64 set_real_ip_from 10.0.0.0/8;
65 set_real_ip_from 172.16.0.0/12;
66 set_real_ip_from 192.168.0.0/16;
67 real_ip_header X-Forwarded-For;
68 real_ip_recursive on;
69
70 location / {
71 rewrite ^ /index.php$uri;
72 }
73
74 location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
75 deny all;
76 }
77 location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
78 deny all;
79 }
80
81 location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
82 fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
83 set $path_info $fastcgi_path_info;
84 try_files $fastcgi_script_name =404;
85 include fastcgi_params;
86 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
87 fastcgi_param PATH_INFO $path_info;
88 fastcgi_param HTTPS on;
89 # Avoid sending the security headers twice
90 fastcgi_param modHeadersAvailable true;
91 # Enable pretty urls
92 fastcgi_param front_controller_active true;
93 fastcgi_pass phpfpm:9002;
94 fastcgi_intercept_errors on;
95 fastcgi_request_buffering off;
96 client_max_body_size 0;
97 fastcgi_read_timeout 1200;
98 }
99
100 location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
101 try_files $uri/ =404;
102 index index.php;
103 }
104
105 location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
106 try_files $uri /index.php$request_uri;
107 add_header Cache-Control "public, max-age=15778463";
108 add_header Referrer-Policy "no-referrer" always;
109 add_header X-Content-Type-Options "nosniff" always;
110 add_header X-Download-Options "noopen" always;
111 add_header X-Frame-Options "SAMEORIGIN" always;
112 add_header X-Permitted-Cross-Domain-Policies "none" always;
113 add_header X-Robots-Tag "none" always;
114 add_header X-XSS-Protection "1; mode=block" always;
115 access_log off;
116 }
117
118 location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
119 try_files $uri /index.php$request_uri;
120 access_log off;
121 }
122}