-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
106 lines (88 loc) · 3.29 KB
/
Copy pathnginx.conf
File metadata and controls
106 lines (88 loc) · 3.29 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# HTTPS config — deployed AFTER SSL certificates exist
# Run scripts/init-ssl.sh to obtain certs and swap this into place
server {
listen 80;
server_name drmath.trelolabs.com;
# ACME challenge for Let's Encrypt renewal
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
# Redirect all HTTP to HTTPS
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name drmath.trelolabs.com;
# Dedicated logs for DPDPA-aligned retention (see scripts/logrotate-drmath.conf)
access_log /var/log/nginx/drmath-access.log combined;
error_log /var/log/nginx/drmath-error.log;
ssl_certificate /etc/letsencrypt/live/drmath.trelolabs.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/drmath.trelolabs.com/privkey.pem;
# SSL security hardening
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
# HSTS — force HTTPS for 6 months
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;
# Security headers
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 "geolocation=(), microphone=(), camera()" always;
# Hide nginx version
server_tokens off;
# Direct-download APK artifacts
location /mathwise.apk {
alias /usr/share/nginx/html/static/mathwise.apk;
add_header Content-Disposition "attachment; filename=mathwise.apk";
}
location /voter-survey.apk {
alias /usr/share/nginx/html/static/voter-survey.apk;
add_header Content-Disposition "attachment; filename=voter-survey.apk";
}
# PWA landing page for nursing module
location = /nursing {
return 301 /nursing/;
}
location /nursing/ {
alias /usr/share/nginx/html/nursing/;
expires 7d;
add_header Cache-Control "public, must-revalidate";
try_files $uri $uri.html $uri/ /nursing/index.html;
}
# Static files served directly by nginx
location /static/ {
alias /usr/share/nginx/html/static/;
expires 7d;
add_header Cache-Control "public, immutable";
}
# Rate limiting for API endpoints
location /api/ {
limit_req zone=drmath_api burst=10 nodelay;
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Rate limiting for general traffic
location / {
limit_req zone=drmath burst=20 nodelay;
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# Redirect www to non-www (HTTPS)
server {
listen 80;
server_name www.drmath.trelolabs.com;
return 301 https://drmath.trelolabs.com$request_uri;
}