statichtmlsite.conf 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 on;
  28. ssl_certificate /etc/nginx/ssl/${SERVICE_DOMAIN}/cert.pem;
  29. ssl_certificate_key /etc/nginx/ssl/${SERVICE_DOMAIN}/key.pem;
  30. include /etc/nginx/includes/ssl.conf;
  31. add_header X-Content-Type-Options "nosniff" always;
  32. add_header X-XSS-Protection "1; mode=block" always;
  33. add_header X-Frame-Options "DENY" always;
  34. add_header Referrer-Policy "strict-origin" always;
  35. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
  36. server_tokens off;
  37. include /etc/nginx/includes/gzip.conf;
  38. location / {
  39. #try_files $uri $uri/ =404;
  40. try_files $uri $uri/ /index.php?q=$uri&$args;
  41. }
  42. expires $expires;
  43. location ~* \.(js|css|xml|gz)$ {
  44. add_header Vary "Accept-Encoding";
  45. }
  46. # custom error pages
  47. fastcgi_intercept_errors on; # make custom errors work
  48. error_page 500 502 503 504 /errors/50x.html;
  49. location = /50x.html {
  50. root /var/www/errors;
  51. }
  52. error_page 403 /errors/403.html;
  53. location = /403.html {
  54. root /var/www/errors;
  55. }
  56. error_page 404 /errors/404.html;
  57. location = /404.html {
  58. }
  59. location ^~ /.well-known/ {
  60. access_log off;
  61. log_not_found off;
  62. root /var/www/html;
  63. # autoindex off;
  64. index index.html; # "no-such-file.txt",if expected protos don't need it
  65. try_files $uri $uri/ =404;
  66. }
  67. }