123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- ##
- # You should look at the following URL's in order to grasp a solid understanding
- # of Nginx configuration files in order to fully unleash the power of Nginx.
- # http://wiki.nginx.org/Pitfalls
- # http://wiki.nginx.org/QuickStart
- # http://wiki.nginx.org/Configuration
- #
- # Generally, you will want to move this file somewhere, and start with a clean
- # file but keep this around for reference. Or just disable in sites-enabled.
- #
- # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
- ##
- # Default server configuration
- #
- map $sent_http_content_type $expires {
- default off;
- text/html epoch;
- text/css max;
- application/javascript max;
- ~image/ max;
- }
- upstream wordpress {
- server wordpress-service-dockerbunker:80;
- }
- server {
- listen 80;
- server_name ${SERVICE_DOMAIN} *.${SERVICE_DOMAIN};
- return 301 https://$host$request_uri;
- add_header X-Content-Type-Options "nosniff" always;
- add_header X-XSS-Protection "1; mode=block" always;
- add_header X-Frame-Options "DENY" always;
- add_header Referrer-Policy "strict-origin" always;
- add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
- server_tokens off;
- }
- server {
- listen 443;
- server_name ${SERVICE_DOMAIN};
- ssl on;
- ssl_certificate /etc/nginx/ssl/${SERVICE_DOMAIN}/cert.pem;
- ssl_certificate_key /etc/nginx/ssl/${SERVICE_DOMAIN}/key.pem;
- include /etc/nginx/includes/ssl.conf;
- add_header X-Content-Type-Options "nosniff" always;
- add_header X-XSS-Protection "1; mode=block" always;
- add_header X-Frame-Options "SAMEORIGIN" always;
- add_header Referrer-Policy "strict-origin" always;
- add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
- server_tokens off;
- proxy_redirect off;
- proxy_read_timeout 90;
- proxy_connect_timeout 90;
- proxy_redirect off;
- proxy_set_header X-NginX-Proxy true;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto https;
- proxy_set_header X-Forwarded-Port 443;
- proxy_set_header Host $host;
- proxy_set_header X-Forwarded-Host $host;
- proxy_set_header X-Forwarded-Server $host;
- include /etc/nginx/includes/gzip.conf;
- location / {
- proxy_pass http://wordpress/;
- proxy_set_header Host $http_host; # required for docker client's sake
- proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- proxy_read_timeout 900;
- }
- location ^~ /wp-login.php {
- ${AUTH_SWITCH} include /etc/nginx/conf.d/${SERVICE_DOMAIN}/basic_auth.conf;
- proxy_pass http://wordpress/$request_uri;
- }
-
- # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
- location ~ /\. {
- deny all;
- access_log off;
- log_not_found off;
- }
- location = /xmlrpc.php {
- deny all;
- log_not_found off;
- access_log off;
- }
-
- location ~* /wp-content/.*.php$ {
- deny all;
- access_log off;
- log_not_found off;
- }
- location ~* /wp-includes/.*.php$ {
- deny all;
- access_log off;
- log_not_found off;
- }
- location ~* /(?:uploads|files)/.*.php$ {
- deny all;
- access_log off;
- log_not_found off;
- }
- location ^~ /.well-known/ {
- access_log off;
- log_not_found off;
- root /var/www/html;
- autoindex off;
- index index.html; # "no-such-file.txt",if expected protos don't need it
- try_files $uri $uri/ =404;
- }
- }
|