-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathnginx.conf
More file actions
91 lines (78 loc) · 2.86 KB
/
nginx.conf
File metadata and controls
91 lines (78 loc) · 2.86 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
events {
worker_connections 1024;
}
http {
client_max_body_size 500M;
upstream frontend {
server frontend:5173;
}
upstream backend {
server backend:8000;
}
upstream fastapi {
server fastapi:3000;
}
# Redirect HTTP → HTTPS
server {
listen 80;
server_name trykimu.com www.trykimu.com;
return 301 https://$host$request_uri;
}
# HTTPS server with TLS + HSTS
server {
listen 443 ssl;
server_name trykimu.com www.trykimu.com;
ssl_certificate /etc/letsencrypt/live/trykimu.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/trykimu.com/privkey.pem;
# Security Headers
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
# trykimu.com/ai/api/ai → http://fastapi/ai
location /ai/api/ {
rewrite ^/ai/api/(.*)$ /$1 break;
proxy_pass http://fastapi;
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_read_timeout 900s;
proxy_send_timeout 900s;
proxy_request_buffering off;
}
# trykimu.com/render/render → http://backend/render
location /render/ {
rewrite ^/render/(.*)$ /$1 break;
proxy_pass http://backend;
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_read_timeout 900s;
proxy_send_timeout 900s;
proxy_request_buffering off;
}
# trykimu.com/api/assets → http://frontend/api/assets (authenticated asset access)
location /api/assets {
proxy_pass http://frontend;
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_read_timeout 900s;
proxy_send_timeout 900s;
proxy_request_buffering off;
client_max_body_size 500M;
}
# Block direct access to /media/* - all asset access must go through authenticated API
location /media {
return 403;
}
# trykimu.com/learn → http://frontend/learn
location / {
proxy_pass http://frontend;
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;
}
}
}