awacke1 commited on
Commit
9b47a8c
Β·
verified Β·
1 Parent(s): 87d304e

Create nginx.conf

Browse files
Files changed (1) hide show
  1. nginx.conf +43 -0
nginx.conf ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # nginx.conf πŸ§™β€β™‚οΈβœ¨ (one port to rule them all: 7860)
2
+ worker_processes 1;
3
+
4
+ events { worker_connections 1024; }
5
+
6
+ http {
7
+ sendfile on;
8
+ tcp_nopush on;
9
+ tcp_nodelay on;
10
+
11
+ # logs off = quieter (and less β€œwhy are we yelling?”)
12
+ access_log off;
13
+ error_log /dev/stderr warn;
14
+
15
+ upstream fastapi_upstream { server 127.0.0.1:8000; }
16
+ upstream streamlit_upstream { server 127.0.0.1:8501; }
17
+
18
+ server {
19
+ listen 7860;
20
+
21
+ # βœ… FastAPI JSON endpoints
22
+ location /api/ {
23
+ proxy_pass http://fastapi_upstream/;
24
+ proxy_set_header Host $host;
25
+ proxy_set_header X-Forwarded-Proto $scheme;
26
+ }
27
+
28
+ # βœ… Streamlit admin console (websocket-y)
29
+ location /admin/ {
30
+ proxy_pass http://streamlit_upstream/;
31
+ proxy_http_version 1.1;
32
+ proxy_set_header Host $host;
33
+
34
+ # Websocket headers πŸ”Œ
35
+ proxy_set_header Upgrade $http_upgrade;
36
+ proxy_set_header Connection "upgrade";
37
+ proxy_read_timeout 86400;
38
+ }
39
+
40
+ # Root -> admin (because β€œwhere am I?” should be answered kindly πŸ˜„)
41
+ location = / { return 302 /admin/; }
42
+ }
43
+ }