statichtmlsite.conf 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Expires map
  2. map $sent_http_content_type $expires {
  3. default off;
  4. text/html epoch;
  5. text/css max;
  6. application/javascript max;
  7. ~image/ max;
  8. }
  9. server {
  10. listen 80;
  11. listen [::]:80;
  12. server_name ${SERVICE_DOMAIN};
  13. return 301 https://$http_host$request_uri;
  14. add_header X-Content-Type-Options "nosniff" always;
  15. add_header X-XSS-Protection "1; mode=block" always;
  16. add_header X-Frame-Options "DENY" always;
  17. add_header Referrer-Policy "strict-origin" always;
  18. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
  19. server_tokens off;
  20. }
  21. server {
  22. server_name ${SERVICE_DOMAIN};
  23. root /var/www/html/${SERVICE_DOMAIN};
  24. index index.html index.htm;
  25. listen 443 ssl;
  26. # listen [::]:443 ipv6only=on ssl;
  27. ssl_certificate /etc/nginx/ssl/${SERVICE_DOMAIN}/cert.pem;
  28. ssl_certificate_key /etc/nginx/ssl/${SERVICE_DOMAIN}/key.pem;
  29. include /etc/nginx/includes/ssl.conf;
  30. add_header X-Content-Type-Options "nosniff" always;
  31. add_header X-XSS-Protection "1; mode=block" always;
  32. add_header X-Frame-Options "DENY" always;
  33. add_header Referrer-Policy "strict-origin" always;
  34. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
  35. server_tokens off;
  36. include /etc/nginx/includes/gzip.conf;
  37. location / {
  38. try_files $uri $uri/ =404;
  39. }
  40. expires $expires;
  41. location ~* \.(js|css|xml|gz)$ {
  42. add_header Vary "Accept-Encoding";
  43. }
  44. # custom error pages
  45. fastcgi_intercept_errors on; # make custom errors work
  46. error_page 500 502 503 504 /50x.html;
  47. location = /50x.html {
  48. root /var/www/html/errors/;
  49. internal;
  50. }
  51. error_page 403 /403.html;
  52. location = /403.html {
  53. root /var/www/html/errors/;
  54. internal;
  55. }
  56. error_page 404 /404.html;
  57. location = /404.html {
  58. root /var/www/html/errors/;
  59. internal;
  60. }
  61. location ^~ /.well-known/ {
  62. access_log off;
  63. log_not_found off;
  64. root /var/www/html;
  65. # autoindex off;
  66. index index.html; # "no-such-file.txt",if expected protos don't need it
  67. try_files $uri $uri/ =404;
  68. }
  69. }