Repository navigation
Expand file tree
/
Copy pathnginx.conf
More file actions
76 lines (61 loc) · 3.64 KB
/
Copy pathnginx.conf
File metadata and controls
76 lines (61 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
worker_processes auto;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# OWASP: hide version info
server_tokens off;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
# Temp paths writable by the unprivileged nginx user
client_body_temp_path /tmp/client_body;
proxy_temp_path /tmp/proxy;
fastcgi_temp_path /tmp/fastcgi;
uwsgi_temp_path /tmp/uwsgi;
scgi_temp_path /tmp/scgi;
# Compression
gzip on;
gzip_vary on;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/javascript
text/xml application/xml text/javascript image/svg+xml;
# Rate limiting — 30 req/s per IP, burst of 60
limit_req_zone $binary_remote_addr zone=main:10m rate=30r/s;
# Cache-Control: long-term immutable for hashed assets, no-store for HTML
map $uri $cache_control_val {
~*\.html$ "no-cache, no-store, must-revalidate";
default "public, max-age=31536000, immutable";
}
map $uri $expires_val {
~*\.html$ epoch;
default max;
}
server {
listen 8080;
root /usr/share/nginx/html/browser;
index index.html;
autoindex off;
limit_req zone=main burst=60 nodelay;
expires $expires_val;
# Security headers (OWASP A05 / CWE-693)
add_header Cache-Control $cache_control_val always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://cdn.simpleicons.org https://mirrors.creativecommons.org https://upload.wikimedia.org https://cdn.phaser.io https://image.pngaaa.com https://logowik.com https://webhostinggeeks.com https://avatars.githubusercontent.com https://duckduckgo.com https://external-content.duckduckgo.com https://www.pngmart.com https://images.seeklogo.com https://www.clipartmax.com; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none';" always;
# Restrict to safe HTTP methods only
if ($request_method !~ ^(GET|HEAD|POST)$) {
return 405;
}
# SPA fallback — serves index.html for any unknown path
location / {
try_files $uri $uri/ /index.html;
}
}
}