
#upstream webservers { 
#    server 0.0.0.0:5000 weight=1;
#}

location / {
    try_files $uri $uri/ /index.html;
    add_header access-control-allow-origin *;
}

location ^~ /api/ {
    add_header        access-control-allow-origin *;
    proxy_pass        http://webservers;
    proxy_set_header  X-Forwarded-Host $host:$server_port;
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  Origin        $host:$server_port;
    proxy_set_header  Referer       $host:$server_port;
}

location ^~ /socket.io/ {
    add_header        access-control-allow-origin *;
    proxy_pass        http://webservers;
    proxy_set_header  X-Forwarded-Host $host:$server_port;
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  Origin        $host:$server_port;
    proxy_set_header  Referer       $host:$server_port;
    proxy_set_header  Host $http_host;
    proxy_set_header  X-NginX-Proxy true;

    # WebScoket Support
    proxy_http_version 1.1;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection "upgrade";
}