-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
87 lines (74 loc) · 2.97 KB
/
nginx.conf
File metadata and controls
87 lines (74 loc) · 2.97 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
# ─────────────────────────────────────────────
# JurisFind – Nginx config for Azure VM
#
# Deploy steps on the VM:
# sudo cp nginx.conf /etc/nginx/sites-available/jurisfind
# sudo ln -s /etc/nginx/sites-available/jurisfind /etc/nginx/sites-enabled/
# sudo rm -f /etc/nginx/sites-enabled/default
# sudo nginx -t && sudo systemctl reload nginx
#
# After you get a domain / SSL cert via Certbot:
# sudo certbot --nginx -d yourdomain.com
# ─────────────────────────────────────────────
upstream jurisfind_api {
server 127.0.0.1:8000;
keepalive 32;
}
# Rate limiting zone — prevents API abuse
limit_req_zone $binary_remote_addr zone=api_limit:10m rate=30r/m;
server {
listen 80;
listen [::]:80;
# ── Replace with your VM's public IP or domain ──
# server_name yourdomain.com www.yourdomain.com;
server_name _;
# Large body size for PDF uploads (max 20MB)
client_max_body_size 20M;
# Gzip responses
gzip on;
gzip_types application/json text/plain text/html application/javascript;
gzip_min_length 1024;
# Security headers
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header X-XSS-Protection "1; mode=block" always;
# ── API Proxy ──
location /api/ {
limit_req zone=api_limit burst=20 nodelay;
proxy_pass http://jurisfind_api;
proxy_http_version 1.1;
proxy_set_header Connection "";
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 — analysis can take up to 90s on first run
proxy_read_timeout 120s;
proxy_connect_timeout 10s;
proxy_send_timeout 120s;
}
# ── FastAPI interactive docs (accessible during dev/testing) ──
location ~ ^/(docs|redoc|openapi.json) {
proxy_pass http://jurisfind_api;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
# ── Root health check ──
location / {
proxy_pass http://jurisfind_api;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
}
# ─── HTTPS block (Certbot will fill this in automatically) ────────────────────
# server {
# listen 443 ssl;
# server_name yourdomain.com;
#
# ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
# include /etc/letsencrypt/options-ssl-nginx.conf;
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
#
# # (same location blocks as above)
# }