SSE server reliability improvements

This commit is contained in:
Ian Renton
2026-06-05 16:06:33 +01:00
parent af1974f36d
commit a2dff07c0e
12 changed files with 93 additions and 42 deletions

View File

@@ -246,8 +246,9 @@ To set up nginx as a reverse proxy that sits in front of Spothole, first ensure
Create a file at `/etc/nginx/sites-available/` called `spothole`. Give it the following contents, replacing `spothole.app` with the domain name on which you want to run Spothole. If you changed the port on which Spothole runs, update that on the "proxy_pass" line too.
```nginx
map $request_uri $xssorigin {
map $request_uri $cors_origin {
~^/api *;
default "";
}
server {
@@ -258,12 +259,46 @@ server {
alias /var/www/html/.well-known/;
}
# SSE endpoints
location ~ ^/api/v1/(spots|alerts)/stream {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://127.0.0.1:8081;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 24h;
proxy_connect_timeout 10s;
proxy_send_timeout 24h;
proxy_set_header X-Accel-Buffering no;
proxy_hide_header Access-Control-Allow-Origin;
add_header Access-Control-Allow-Origin $cors_origin always;
add_header Cache-Control no-store always;
add_header Content-Type text/event-stream always;
}
# Other API endpoints
location /api/ {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://127.0.0.1:8081;
proxy_buffering on;
proxy_cache off;
proxy_read_timeout 30s;
proxy_connect_timeout 10s;
proxy_hide_header Access-Control-Allow-Origin;
add_header Access-Control-Allow-Origin $cors_origin always;
add_header Cache-Control no-store always;
}
# Static assets
location / {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://127.0.0.1:8080;
proxy_hide_header Access-Control-Allow-Origin;
add_header Access-Control-Allow-Origin $xssorigin;
proxy_pass http://127.0.0.1:8081;
proxy_buffering on;
proxy_read_timeout 30s;
proxy_connect_timeout 10s;
add_header Cache-Control "public, max-age=3600, must-revalidate" always;
}
}
```