| 1 | # suitably anonymised
|
|---|
| 2 | server {
|
|---|
| 3 | listen 1.2.3.4:80;
|
|---|
| 4 | listen 1.2.3.4:443 ssl;
|
|---|
| 5 | server_name mydomain.com
|
|---|
| 6 |
|
|---|
| 7 | root /var/websites/mydomain/wordpress;
|
|---|
| 8 | index index.php index.html index.htm;
|
|---|
| 9 |
|
|---|
| 10 | access_log /var/websites/mydomain/log/access-nginx.log;
|
|---|
| 11 |
|
|---|
| 12 | #rewrite_log on;
|
|---|
| 13 | error_log /var/websites/mydomain.com/log/errors-nginx.log debug;
|
|---|
| 14 |
|
|---|
| 15 | ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
|
|---|
| 16 | ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
|
|---|
| 17 | ssl_trusted_certificate /etc/letsencrypt/live/mydomain.com/chain.pem;
|
|---|
| 18 |
|
|---|
| 19 | include /etc/nginx/strong_ssl_options;
|
|---|
| 20 | ssl_dhparam /etc/ssl/certs/dhparam.pem;
|
|---|
| 21 |
|
|---|
| 22 | set $wordpress_auth "";
|
|---|
| 23 | if ($http_cookie ~* "wordpress_logged_in_[^=]*=([^%]+)%7C") {
|
|---|
| 24 | set $wordpress_auth wordpress_logged_in_$1;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | location / {
|
|---|
| 28 | # redirect insecure requests to https
|
|---|
| 29 | if ( $scheme != "https" ) {
|
|---|
| 30 | return 301 https://$host$request_uri;
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | if ( $scheme = "https" ) {
|
|---|
| 34 | add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | if (!-e $request_filename) {
|
|---|
| 38 | rewrite ^.*$ /index.php last;
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | location ~ [^/]\.php(/|$) {
|
|---|
| 43 | if ( $request_uri ~ ^([^?]+?\.php)?(?<my_path_info>\/[^?]*?)?(\?.*)?$ ) {
|
|---|
| 44 | # deliberately empty block
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | if ( $my_path_info = "" ) {
|
|---|
| 48 | set $my_path_info "/";
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | fastcgi_param PATH_INFO $my_path_info;
|
|---|
| 52 | fastcgi_param PATH_TRANSLATED $document_root$my_path_info;
|
|---|
| 53 |
|
|---|
| 54 | include fastcgi_params; # these are in /etc/nginx
|
|---|
| 55 |
|
|---|
| 56 | fastcgi_index index.php;
|
|---|
| 57 |
|
|---|
| 58 | # php-fpm is configured in /etc/nginx/conf.d/00_upstream_backends.conf
|
|---|
| 59 | fastcgi_pass php-fpm;
|
|---|
| 60 |
|
|---|
| 61 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|---|
| 62 |
|
|---|
| 63 | #fastcgi_intercept_errors on;
|
|---|
| 64 |
|
|---|
| 65 | # Mitigate https://httpoxy.org/ vulnerabilities
|
|---|
| 66 | fastcgi_param HTTP_PROXY "";
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | }
|
|---|