Spaces:
Sleeping
Sleeping
Create nginx.conf
Browse files- 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 |
+
}
|