server {
    listen 80;
    server_name _;

    # redirect service to tethering IP for 'webview kiosk' -> mobile phone to face
    location /redirect {
        proxy_pass http://127.0.0.1:8000/redirect;
	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    # captive portal to face
    include /opt/helva-robot/drive/etc/nginx/snippets/captive-portal.conf;

    # gives access to drive control
    include /opt/helva-robot/drive/etc/nginx/snippets/drive.conf;

    root /opt/helva-robot/face/var/www/html;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }

    # API -> backend
    location /api/ {
        proxy_pass http://127.0.0.1:8001;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    # SSE stream -> backend
    location /events {
        proxy_pass http://127.0.0.1:8001/events;
        proxy_http_version 1.1;
        proxy_set_header Host $host;

        proxy_buffering off;          # IMPORTANT for SSE
        proxy_cache off;
        proxy_read_timeout 1h;
        proxy_send_timeout 1h;

        add_header Cache-Control no-cache;
    }

}

