Repository navigation
Expand file tree
/
Copy pathnginx.conf
More file actions
83 lines (72 loc) · 3.02 KB
/
Copy pathnginx.conf
File metadata and controls
83 lines (72 loc) · 3.02 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
# /etc/nginx/sites-available/sync-backend
# Symlink: sudo ln -s /etc/nginx/sites-available/sync-backend /etc/nginx/sites-enabled/
# Rate limiting zone — 10 req/sec per IP, burst of 20
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
server {
listen 80;
server_name YOUR_DOMAIN_OR_IP; # <-- replace this
# Redirect all HTTP to HTTPS once you have SSL set up
# Comment this block out until you run certbot
# return 301 https://$host$request_uri;
# ── Proxy to Node.js ──────────────────────────────────────────────────────
location / {
limit_req zone=api burst=20 nodelay;
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
# Required for Express to see the real client IP
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;
# Timeouts — gives Node enough time for slow DB queries without hanging forever
proxy_connect_timeout 10s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
# Buffer responses so slow clients don't hold Node connections open
proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 8 8k;
}
# Block common scanner paths to save request budget
location ~* ^/(wp-admin|\.env|\.git|phpinfo) {
return 404;
}
# Nginx-level gzip (catches anything the Node compression middleware might miss)
gzip on;
gzip_types application/json text/plain application/javascript;
gzip_min_length 1024;
}
# ── HTTPS block — uncomment after running certbot ─────────────────────────────
# server {
# listen 443 ssl http2;
# server_name YOUR_DOMAIN;
#
# ssl_certificate /etc/letsencrypt/live/YOUR_DOMAIN/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/YOUR_DOMAIN/privkey.pem;
# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_ciphers HIGH:!aNULL:!MD5;
#
# location / {
# limit_req zone=api burst=20 nodelay;
# proxy_pass http://127.0.0.1:8000;
# proxy_http_version 1.1;
# 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;
# proxy_connect_timeout 10s;
# proxy_send_timeout 30s;
# proxy_read_timeout 30s;
# proxy_buffering on;
# proxy_buffer_size 8k;
# proxy_buffers 8 8k;
# }
#
# gzip on;
# gzip_types application/json text/plain application/javascript;
# gzip_min_length 1024;
#
# location ~* ^/(wp-admin|\.env|\.git|phpinfo) {
# return 404;
# }
# }