-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx-https.conf
More file actions
75 lines (64 loc) · 2.11 KB
/
Copy pathnginx-https.conf
File metadata and controls
75 lines (64 loc) · 2.11 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
upstream fastapi {
server app:8000;
}
# Redirect HTTP to HTTPS
server {
listen 80;
server_name _;
# Allow Let's Encrypt challenge (prefix match, highest priority)
location ^~ /.well-known/acme-challenge/ {
root /var/www/certbot;
default_type text/plain;
}
# Redirect all other traffic to HTTPS
location / {
return 301 https://$host$request_uri;
}
}
# HTTPS server
server {
listen 443 ssl http2;
server_name bristolpubcrawl.xyz www.bristolpubcrawl.xyz;
client_max_body_size 10M;
# SSL certificates (will be managed by Certbot)
# This cert includes both bristolpubcrawl.xyz and www.bristolpubcrawl.xyz
ssl_certificate /etc/letsencrypt/live/bristolpubcrawl.xyz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/bristolpubcrawl.xyz/privkey.pem;
# SSL configuration
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Gzip compression
gzip on;
gzip_types text/plain text/css text/javascript application/json application/javascript;
gzip_min_length 1000;
# All API endpoints - proxy to FastAPI
location /api/ {
proxy_pass http://fastapi;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
}
# FastAPI docs (keep for backward compatibility)
location ~ ^/(docs|openapi.json|redoc)$ {
proxy_pass http://fastapi;
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;
}
# Serve static files (HTML, CSS, JS)
location / {
root /app;
try_files $uri $uri/ /index.html;
}
# Deny access to .files (like .env)
location ~ /\. {
deny all;
}
}