MicProtocol / deploy /nginx.conf
Benaah's picture
Upload deploy/nginx.conf with huggingface_hub
f34d042 verified
Raw History Blame Contribute Delete
3.04 kB
# Nginx reverse proxy for MicProtocol all-in-one HF Space.
# Listens on __APP_PORT__ (replaced with APP_PORT at build time) and
# routes by path to the local services.
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
upstream api { server 127.0.0.1:4000; }
upstream web { server 127.0.0.1:3000; }
upstream admin{ server 127.0.0.1:3006; }
upstream rt { server 127.0.0.1:4001; }
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen __APP_PORT__;
listen [::]:__APP_PORT__;
server_name _;
# Health
location = /health {
proxy_pass http://api;
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;
}
# API + tRPC (global prefix "api")
location ~ ^/(api|trpc)/ {
proxy_pass http://api;
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 300s;
}
# Real-time collaboration (WebSocket + internal HTTP)
location = /ws {
proxy_pass http://rt/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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;
proxy_read_timeout 300s;
}
location /ws/ {
proxy_pass http://rt/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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;
proxy_read_timeout 300s;
}
# Admin app
location /admin/ {
proxy_pass http://admin/;
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;
}
# Web app (catch-all)
location / {
proxy_pass http://web/;
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;
}
}
}