|
| 1 | +{ |
| 2 | + admin off |
| 3 | +} |
| 4 | + |
1 | 5 | (common) { |
2 | | - encode zstd gzip |
| 6 | + encode zstd gzip |
| 7 | + |
3 | 8 | file_server |
| 9 | + |
| 10 | + respond /healthcheck "UP" 200 |
4 | 11 | } |
5 | 12 |
|
6 | 13 | (ssl) { |
7 | | - tls internal |
| 14 | + tls {$TLS} { |
| 15 | + on_demand |
| 16 | + } |
8 | 17 | } |
9 | 18 |
|
10 | | -{$HOSTNAME} { |
| 19 | +(custom_domain) { |
11 | 20 | import common |
12 | 21 | import ssl |
13 | 22 |
|
14 | | - respond /healthcheck 200 |
| 23 | + ### |
| 24 | + # Domain related |
| 25 | + ### |
15 | 26 |
|
16 | | - root * /var/www/html/public |
| 27 | + @strip_www { |
| 28 | + header_regexp www Host ^www\.(.*)$ |
| 29 | + } |
| 30 | + redir @strip_www https://{http.regexp.www.1}{uri} |
| 31 | + |
| 32 | + ### |
| 33 | + # Cache |
| 34 | + ### |
| 35 | + |
| 36 | + header { |
| 37 | + Cache-Control "public, max-age=31536000" |
| 38 | + } |
| 39 | + |
| 40 | + @static { |
| 41 | + file |
| 42 | + path *.avif *.ico *.css *.js *.gz *.eot *.ttf *.otf *.gif *.webp *.avif *.jpg *.jpeg *.png *.svg *.woff *.woff2 *.pdf |
| 43 | + } |
| 44 | + header @static Cache-Control "max-age=31536000,public,inmutable" |
| 45 | + |
| 46 | + @html { |
| 47 | + path *.html *.htm |
| 48 | + } |
| 49 | + header @html { |
| 50 | + Cache-Control "public, max-age=43200" |
| 51 | + } |
| 52 | + |
| 53 | + ### |
| 54 | + # Security |
| 55 | + ### |
| 56 | + |
| 57 | + header { |
| 58 | + Strict-Transport-Security "max-age=31536000;includeSubDomains;preload" |
| 59 | + X-Frame-Options "SAMEORIGIN" |
| 60 | + X-Xss-Protection "1;mode=block" |
| 61 | + Referrer-Policy "no-referrer-when-downgrade" |
| 62 | + X-Content-Type-Options "nosniff" |
| 63 | + Permissions-Policy "autoplay=(self),camera=(),geolocation=(),microphone=(),payment=(),usb=()" |
| 64 | + |
| 65 | + # Review |
| 66 | + #?Content-Security-Policy "default-src 'self';script-src 'self';style-src 'self'" |
| 67 | + } |
| 68 | + |
| 69 | + @requestMethodsList { |
| 70 | + not method GET HEAD POST OPTIONS |
| 71 | + } |
| 72 | + respond @requestMethodsList "Not Allowed" 405 { |
| 73 | + close |
| 74 | + } |
| 75 | + |
| 76 | + ### |
| 77 | + # 404 |
| 78 | + ### |
| 79 | + |
| 80 | + @static_404 { |
| 81 | + path_regexp \.(jpg|jpeg|png|webp|gif|avif|ico|svg|css|js|gz|eot|ttf|otf|woff|woff2|pdf)$ |
| 82 | + not file |
| 83 | + } |
| 84 | + |
| 85 | + respond @static_404 "Not Found" 404 { |
| 86 | + close |
| 87 | + } |
| 88 | + |
| 89 | + ### |
| 90 | + # PHP-FPM |
| 91 | + ### |
17 | 92 |
|
18 | 93 | php_fastcgi {$PHP_FPM_GATEWAYS} { |
19 | 94 | index index.php |
|
23 | 98 | lb_policy round_robin |
24 | 99 | } |
25 | 100 | } |
| 101 | + |
| 102 | +:80 { |
| 103 | + import common |
| 104 | + import ssl |
| 105 | +} |
| 106 | + |
| 107 | +{$HOSTNAME}, www.{$HOSTNAME} { |
| 108 | + import custom_domain |
| 109 | + root * /var/www/html/public |
| 110 | +} |
0 commit comments