|
| 1 | +#=========================================================================# |
| 2 | +# Default Web Domain Template # |
| 3 | +# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS # |
| 4 | +# https://hestiacp.com/docs/server-administration/web-templates.html # |
| 5 | +#=========================================================================# |
| 6 | + |
| 7 | +server { |
| 8 | + listen %ip%:%web_ssl_port% ssl; |
| 9 | + server_name %domain_idn% %alias_idn%; |
| 10 | + root %sdocroot%; |
| 11 | + index index.php index.html index.htm; |
| 12 | + access_log /var/log/nginx/domains/%domain%.log combined; |
| 13 | + access_log /var/log/nginx/domains/%domain%.bytes bytes; |
| 14 | + error_log /var/log/nginx/domains/%domain%.error.log error; |
| 15 | + |
| 16 | + ssl_certificate %ssl_pem%; |
| 17 | + ssl_certificate_key %ssl_key%; |
| 18 | + ssl_stapling on; |
| 19 | + ssl_stapling_verify on; |
| 20 | + |
| 21 | + # TLS 1.3 0-RTT anti-replay |
| 22 | + if ($anti_replay = 307) { return 307 https://$host$request_uri; } |
| 23 | + if ($anti_replay = 425) { return 425; } |
| 24 | + |
| 25 | + include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*; |
| 26 | + |
| 27 | + # Rewrite requests to /wp-.* on subdirectory installs. |
| 28 | + if (!-e $request_filename) { |
| 29 | + rewrite /wp-admin$ $scheme://$host$uri/ permanent; |
| 30 | + rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last; |
| 31 | + rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last; |
| 32 | + } |
| 33 | + |
| 34 | + location = /favicon.ico { |
| 35 | + log_not_found off; |
| 36 | + access_log off; |
| 37 | + } |
| 38 | + |
| 39 | + location = /robots.txt { |
| 40 | + try_files $uri $uri/ /index.php?$args; |
| 41 | + log_not_found off; |
| 42 | + access_log off; |
| 43 | + } |
| 44 | + |
| 45 | + location ~ /\.(?!well-known\/) { |
| 46 | + deny all; |
| 47 | + return 404; |
| 48 | + } |
| 49 | + |
| 50 | + location / { |
| 51 | + try_files $uri $uri/ /index.php?$args; |
| 52 | + |
| 53 | + location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|webp|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ { |
| 54 | + expires 30d; |
| 55 | + fastcgi_hide_header "Set-Cookie"; |
| 56 | + } |
| 57 | + |
| 58 | + location ~* /(?:uploads|files)/.*.php$ { |
| 59 | + deny all; |
| 60 | + return 404; |
| 61 | + } |
| 62 | + |
| 63 | + location ~ [^/]\.php(/|$) { |
| 64 | + try_files $uri =404; |
| 65 | + |
| 66 | + include /etc/nginx/fastcgi_params; |
| 67 | + |
| 68 | + fastcgi_index index.php; |
| 69 | + fastcgi_param HTTP_EARLY_DATA $rfc_early_data if_not_empty; |
| 70 | + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 71 | + |
| 72 | + fastcgi_pass %backend_lsnr%; |
| 73 | + |
| 74 | + include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*; |
| 75 | + |
| 76 | + if ($request_uri ~* "/wp-admin/|/wp-json/|wp-.*.php|xmlrpc.php|index.php|/store.*|/cart.*|/my-account.*|/checkout.*") { |
| 77 | + set $no_cache 1; |
| 78 | + } |
| 79 | + |
| 80 | + if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart|woocommerce_cart_hash|PHPSESSID") { |
| 81 | + set $no_cache 1; |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + location /error/ { |
| 87 | + alias %home%/%user%/web/%domain%/document_errors/; |
| 88 | + } |
| 89 | + |
| 90 | + location /vstats/ { |
| 91 | + alias %home%/%user%/web/%domain%/stats/; |
| 92 | + include %home%/%user%/web/%domain%/stats/auth.conf*; |
| 93 | + } |
| 94 | + |
| 95 | + proxy_hide_header Upgrade; |
| 96 | + |
| 97 | + include /etc/nginx/conf.d/phpmyadmin.inc*; |
| 98 | + include /etc/nginx/conf.d/phppgadmin.inc*; |
| 99 | + include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*; |
| 100 | +} |
0 commit comments