wordpress.conf 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ##
  2. # You should look at the following URL's in order to grasp a solid understanding
  3. # of Nginx configuration files in order to fully unleash the power of Nginx.
  4. # http://wiki.nginx.org/Pitfalls
  5. # http://wiki.nginx.org/QuickStart
  6. # http://wiki.nginx.org/Configuration
  7. #
  8. # Generally, you will want to move this file somewhere, and start with a clean
  9. # file but keep this around for reference. Or just disable in sites-enabled.
  10. #
  11. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
  12. ##
  13. # Default server configuration
  14. #
  15. map $sent_http_content_type $expires {
  16. default off;
  17. text/html epoch;
  18. text/css max;
  19. application/javascript max;
  20. ~image/ max;
  21. }
  22. upstream wordpress {
  23. server wordpress-service-dockerbunker:80;
  24. }
  25. server {
  26. listen 80;
  27. server_name ${SERVICE_DOMAIN} *.${SERVICE_DOMAIN};
  28. return 301 https://$host$request_uri;
  29. add_header X-Content-Type-Options "nosniff" always;
  30. add_header X-XSS-Protection "1; mode=block" always;
  31. add_header X-Frame-Options "DENY" always;
  32. add_header Referrer-Policy "strict-origin" always;
  33. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
  34. server_tokens off;
  35. }
  36. server {
  37. listen 443;
  38. server_name ${SERVICE_DOMAIN};
  39. ssl on;
  40. ssl_certificate /etc/nginx/ssl/${SERVICE_DOMAIN}/cert.pem;
  41. ssl_certificate_key /etc/nginx/ssl/${SERVICE_DOMAIN}/key.pem;
  42. include /etc/nginx/includes/ssl.conf;
  43. add_header X-Content-Type-Options "nosniff" always;
  44. add_header X-XSS-Protection "1; mode=block" always;
  45. add_header X-Frame-Options "SAMEORIGIN" always;
  46. add_header Referrer-Policy "strict-origin" always;
  47. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
  48. server_tokens off;
  49. proxy_redirect off;
  50. proxy_read_timeout 90;
  51. proxy_connect_timeout 90;
  52. proxy_redirect off;
  53. proxy_set_header X-NginX-Proxy true;
  54. proxy_set_header X-Real-IP $remote_addr;
  55. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  56. proxy_set_header X-Forwarded-Proto https;
  57. proxy_set_header X-Forwarded-Port 443;
  58. proxy_set_header Host $host;
  59. proxy_set_header X-Forwarded-Host $host;
  60. proxy_set_header X-Forwarded-Server $host;
  61. include /etc/nginx/includes/gzip.conf;
  62. location / {
  63. proxy_pass http://wordpress/;
  64. proxy_set_header Host $http_host; # required for docker client's sake
  65. proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
  66. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  67. proxy_set_header X-Forwarded-Proto $scheme;
  68. proxy_read_timeout 900;
  69. }
  70. location ^~ /wp-login.php {
  71. ${AUTH_SWITCH} include /etc/nginx/conf.d/${SERVICE_DOMAIN}/basic_auth.conf;
  72. proxy_pass http://wordpress/$request_uri;
  73. }
  74. # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
  75. location ~ /\. {
  76. deny all;
  77. access_log off;
  78. log_not_found off;
  79. }
  80. location = /xmlrpc.php {
  81. deny all;
  82. log_not_found off;
  83. access_log off;
  84. }
  85. location ~* /wp-content/.*.php$ {
  86. deny all;
  87. access_log off;
  88. log_not_found off;
  89. }
  90. location ~* /wp-includes/.*.php$ {
  91. deny all;
  92. access_log off;
  93. log_not_found off;
  94. }
  95. location ~* /(?:uploads|files)/.*.php$ {
  96. deny all;
  97. access_log off;
  98. log_not_found off;
  99. }
  100. location ^~ /.well-known/ {
  101. access_log off;
  102. log_not_found off;
  103. root /var/www/html;
  104. autoindex off;
  105. index index.html; # "no-such-file.txt",if expected protos don't need it
  106. try_files $uri $uri/ =404;
  107. }
  108. }