|
| 1 | +map $request_id $csp_nonce { |
| 2 | + default $request_id; |
| 3 | +} |
| 4 | + |
1 | 5 | server { |
2 | | - listen 80; |
3 | | - root /app; |
| 6 | + listen 80 default_server; |
| 7 | + server_name _; |
| 8 | + |
| 9 | + root /usr/share/nginx/html; |
4 | 10 | index index.html; |
5 | 11 |
|
6 | | - # Set security headers to protect against common web vulnerabilities |
7 | | - add_header X-Frame-Options "DENY"; |
8 | | - add_header X-Content-Type-Options "nosniff"; |
9 | | - add_header X-XSS-Protection "1; mode=block"; |
10 | | - add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; |
11 | | - add_header Content-Security-Policy "default-src 'self' https://*.thefirepanel.com; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' 'nonce-$request_id' https://fonts.googleapis.com; script-src 'unsafe-inline' 'self' 'nonce-$request_id'; font-src 'self' https://fonts.gstatic.com; img-src 'self' https://i.ytimg.com data:; base-uri 'self'; object-src 'none'; connect-src *; frame-src https://www.youtube.com;"; |
| 12 | + # ------------------------- |
| 13 | + # Security headers |
| 14 | + # ------------------------- |
| 15 | + add_header X-Frame-Options "DENY" always; |
| 16 | + add_header X-Content-Type-Options "nosniff" always; |
| 17 | + add_header Referrer-Policy "strict-origin-when-cross-origin" always; |
| 18 | + add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always; |
12 | 19 |
|
| 20 | + add_header Content-Security-Policy " |
| 21 | + default-src 'self' https://*.thefirepanel.com; |
| 22 | + base-uri 'self'; |
| 23 | + object-src 'none'; |
| 24 | + frame-ancestors 'none'; |
| 25 | + worker-src 'self' blob:; |
| 26 | + style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; |
| 27 | + script-src 'self' 'nonce-$csp_nonce'; |
| 28 | + font-src 'self' https://fonts.gstatic.com; |
| 29 | + img-src 'self' https://i.ytimg.com data:; |
| 30 | + connect-src *; |
| 31 | + frame-src https://www.youtube.com; |
| 32 | + " always; |
| 33 | + |
| 34 | + # ------------------------- |
| 35 | + # Redirects |
| 36 | + # ------------------------- |
13 | 37 | location ~ ^/(team|author)/ { |
14 | | - return 301 /about; |
| 38 | + return 308 /about; |
15 | 39 | } |
16 | 40 |
|
17 | 41 | location = /wiki/ndevices/simplexmnc/ { |
18 | | - return 301 /tools; |
| 42 | + return 308 /tools; |
19 | 43 | } |
20 | 44 |
|
21 | 45 | location ~ ^/(wiki|blog|tag)/ { |
22 | | - return 301 https://wiki.thefirepanel.com; |
| 46 | + return 308 https://wiki.thefirepanel.com$request_uri; |
23 | 47 | } |
24 | 48 |
|
25 | | - # Define location block for handling requests |
| 49 | + # ------------------------- |
| 50 | + # SPA handling |
| 51 | + # ------------------------- |
26 | 52 | location / { |
27 | | - # Try serving the requested URI, fall back to index.html if not found |
28 | | - try_files $uri /index.html; |
29 | | - # Enable nonce on app to protect with CSP |
| 53 | + try_files $uri $uri/ /index.html; |
| 54 | + |
30 | 55 | sub_filter_once off; |
31 | | - sub_filter random_nonce_value $request_id; |
| 56 | + sub_filter random_nonce_value $csp_nonce; |
32 | 57 | } |
33 | 58 | } |
0 commit comments