|
| 1 | +upstream php-handler { |
| 2 | + server 127.0.0.1:9000; |
| 3 | +} |
| 4 | + |
| 5 | +server { |
| 6 | + listen {{ .Values.nginx.containerPort | default 80 }}; |
| 7 | + listen [::]:{{ .Values.nginx.containerPort | default 80 }}; |
| 8 | + |
| 9 | + ## HSTS ## |
| 10 | + # Add the 'Strict-Transport-Security' headers to enable HSTS protocol. |
| 11 | + # WARNING: Only add the preload option once you read about the consequences: https://hstspreload.org/. |
| 12 | + # This form will add the domain to a hardcoded list that is shipped in all major browsers and getting |
| 13 | + # removed from this list could take several months. |
| 14 | + # |
| 15 | + #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always; |
| 16 | + |
| 17 | + add_header Referrer-Policy "no-referrer" always; |
| 18 | + add_header X-Content-Type-Options "nosniff" always; |
| 19 | + add_header X-Download-Options "noopen" always; |
| 20 | + add_header X-Frame-Options "SAMEORIGIN" always; |
| 21 | + add_header X-Permitted-Cross-Domain-Policies "none" always; |
| 22 | + add_header X-Robots-Tag "none" always; |
| 23 | + add_header X-XSS-Protection "1; mode=block" always; |
| 24 | + |
| 25 | + # Remove X-Powered-By, which is an information leak |
| 26 | + fastcgi_hide_header X-Powered-By; |
| 27 | + |
| 28 | + root /var/www/html/public; |
| 29 | + |
| 30 | + index index.php index.html index.htm; |
| 31 | + |
| 32 | + charset utf-8; |
| 33 | + |
| 34 | + location / { |
| 35 | + try_files $uri $uri/ /index.php?$query_string; |
| 36 | + } |
| 37 | + |
| 38 | + location ~ ^/(?:robots.txt|security.txt) { |
| 39 | + allow all; |
| 40 | + log_not_found off; |
| 41 | + access_log off; |
| 42 | + } |
| 43 | + |
| 44 | + error_page 404 500 502 503 504 /index.php; |
| 45 | + |
| 46 | + location ~ /\.well-known/(?:carddav|caldav) { |
| 47 | + return 301 $scheme://$host/dav; |
| 48 | + } |
| 49 | + location = /.well-known/security.txt { |
| 50 | + return 301 $scheme://$host/security.txt; |
| 51 | + } |
| 52 | + location ~ /\.(?!well-known).* { |
| 53 | + deny all; |
| 54 | + } |
| 55 | + |
| 56 | + # set max upload size |
| 57 | + client_max_body_size 10G; |
| 58 | + fastcgi_buffers 64 4K; |
| 59 | + |
| 60 | + # Enable gzip but do not remove ETag headers |
| 61 | + gzip on; |
| 62 | + gzip_vary on; |
| 63 | + gzip_comp_level 4; |
| 64 | + gzip_min_length 256; |
| 65 | + gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; |
| 66 | + 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; |
| 67 | + |
| 68 | + # Uncomment if your server is build with the ngx_pagespeed module |
| 69 | + # This module is currently not supported. |
| 70 | + #pagespeed off; |
| 71 | + |
| 72 | + location ~ \.php(?:$|/) { |
| 73 | + # regex to split $uri to $fastcgi_script_name and $fastcgi_path |
| 74 | + fastcgi_split_path_info ^(.+?\.php)(/.*)$; |
| 75 | +
|
| 76 | + # Check that the PHP script exists before passing it |
| 77 | + # try_files $fastcgi_script_name =404; |
| 78 | +
|
| 79 | + fastcgi_pass php-handler; |
| 80 | + fastcgi_index index.php; |
| 81 | +
|
| 82 | + include fastcgi_params; |
| 83 | +
|
| 84 | + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 85 | + # Bypass the fact that try_files resets $fastcgi_path_info |
| 86 | + # see: http://trac.nginx.org/nginx/ticket/321 |
| 87 | + set $path_info $fastcgi_path_info; |
| 88 | + fastcgi_param PATH_INFO $path_info; |
| 89 | + } |
| 90 | + |
| 91 | + # Adding the cache control header for js and css files |
| 92 | + # Make sure it is BELOW the PHP block |
| 93 | + location ~ \.(?:css|js|woff2?|svg|gif|json)$ { |
| 94 | + try_files $uri /index.php$request_uri; |
| 95 | + add_header Cache-Control "public, max-age=15778463"; |
| 96 | +
|
| 97 | + ## HSTS ## |
| 98 | + # Add the 'Strict-Transport-Security' headers to enable HSTS protocol. |
| 99 | + # Note it is intended to have those duplicated to the ones above. |
| 100 | + # WARNING: Only add the preload option once you read about the consequences: https://hstspreload.org/. |
| 101 | + # This form will add the domain to a hardcoded list that is shipped in all major browsers and getting |
| 102 | + # removed from this list could take several months. |
| 103 | + # |
| 104 | + #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always; |
| 105 | +
|
| 106 | + add_header Referrer-Policy "no-referrer" always; |
| 107 | + add_header X-Content-Type-Options "nosniff" always; |
| 108 | + add_header X-Download-Options "noopen" always; |
| 109 | + add_header X-Frame-Options "SAMEORIGIN" always; |
| 110 | + add_header X-Permitted-Cross-Domain-Policies "none" always; |
| 111 | + add_header X-Robots-Tag "none" always; |
| 112 | + add_header X-XSS-Protection "1; mode=block" always; |
| 113 | +
|
| 114 | + # Optional: Don't log access to assets |
| 115 | + access_log off; |
| 116 | + } |
| 117 | +
|
| 118 | + location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ { |
| 119 | + try_files $uri /index.php$request_uri; |
| 120 | +
|
| 121 | + # Optional: Don't log access to assets |
| 122 | + access_log off; |
| 123 | + } |
| 124 | + |
| 125 | + # deny access to .htaccess files |
| 126 | + location ~ /\.ht { |
| 127 | + deny all; |
| 128 | + } |
| 129 | +} |
0 commit comments