upstream ui_rest {
    server localhost:8080;
}

server {
    listen       80;
    server_name  localhost;
    root   /usr/share/stork/www;
    index  index.html;

    location /api {
        proxy_pass http://ui_rest;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_buffering off;
        proxy_set_header Accept-Encoding "";
        proxy_set_header Host $host;
    }

    location /swagger.json {
        proxy_pass http://ui_rest;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_buffering off;
        proxy_set_header Accept-Encoding "";
        proxy_set_header Host $host;
    }

    location /stork-install-agent.sh {
        proxy_pass http://ui_rest;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_buffering off;
        proxy_set_header Accept-Encoding "";
        proxy_set_header Host $host;
    }

    location /metrics {
        allow 127.0.0.1;
        deny all;

        proxy_pass http://ui_rest;
        proxy_buffering off;
        proxy_set_header Accept-Encoding "";
        proxy_set_header Host $host;
    }

    location / {
        try_files $uri $uri/ /index.html;
    }
}
