52 lines
1.6 KiB
Nginx Configuration File
52 lines
1.6 KiB
Nginx Configuration File
# nginx.conf
|
|
server {
|
|
listen 8080;
|
|
server_name localhost;
|
|
|
|
# Static file serving
|
|
location /static/ {
|
|
alias /path/to/your/project/static/;
|
|
expires 1d;
|
|
add_header Cache-Control "public, no-transform";
|
|
}
|
|
|
|
# Proxy all other requests to Flask
|
|
location / {
|
|
proxy_pass http://127.0.0.1:5000;
|
|
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;
|
|
|
|
# SSE specific headers
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
proxy_set_header Connection '';
|
|
proxy_http_version 1.1;
|
|
chunked_transfer_encoding off;
|
|
}
|
|
|
|
# SSE endpoint optimization
|
|
location /events {
|
|
proxy_pass http://127.0.0.1:5000/events;
|
|
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;
|
|
|
|
# Disable buffering for real-time updates
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
proxy_read_timeout 24h;
|
|
proxy_send_timeout 24h;
|
|
proxy_set_header Connection '';
|
|
proxy_http_version 1.1;
|
|
chunked_transfer_encoding off;
|
|
|
|
# CORS headers if needed
|
|
add_header Access-Control-Allow-Origin *;
|
|
add_header Access-Control-Allow-Methods "GET, OPTIONS";
|
|
add_header Access-Control-Allow-Headers "Origin, Content-Type";
|
|
}
|
|
}
|
|
|