events {}
http {
    upstream api {
        server localhost:8081;
    }

    upstream webpack {
        server localhost:8082;
    }

    server {
        listen 8080;
        server_name localhost;

        location /api/ {
            proxy_pass http://api;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header   X-Forwarded-Host $server_name;
        }

        location / {
            proxy_pass http://webpack;
            proxy_pass_header Content-Security-Policy;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header   X-Forwarded-Host $server_name;
        }
    }

    client_max_body_size 10M;
}
