Spaces:
Sleeping
Sleeping
server { | |
listen 7860; | |
# Root directory for the React app | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
# Handle client-side routing for React | |
location / { | |
try_files $uri /index.html; | |
} | |
# Proxy API requests to the backend service | |
# Any request to http://<your-space-url>/api/... | |
# will be forwarded to http://backend:8000/... | |
location /api { | |
proxy_pass http://backend:8000; # 'backend' is the service name in docker-compose.yml | |
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; | |
} | |
# Optional: Improve performance with caching for static assets | |
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg)$ { | |
expires 1y; | |
add_header Cache-Control "public"; | |
} | |
} |