Nginx 反向服务器需要很长时间才能反向到 angular2 实时开发服务器

Nginx reverse server takes to long to reverse to angular2 live development server

我们有一个特殊要求,我必须在开发过程中将 Angular2 Live Development Server (ng serve) 放在反向代理后面。

我的环境:

OS: Windows 10

Angular版本:5

Nginx: 1.14.0

Angular 客户端:1.7.0

Angular 实时开发服务器在 http://localhost:7776

上运行

Nginx 代理服务器在 http://localhost:7777

上运行

我的问题:

如果我在没有代理的情况下直接访问 7776,它会在 1 秒内加载得非常快,但是如果从 7777(反向代理)访问,则需要大约 1 分钟才能完成加载。

我的nginx.conf:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       7777;
        server_name  localhost;

        charset utf-8;

        location /sockjs-node {
            proxy_buffering off;
            proxy_pass http://localhost:7776/sockjs-node;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
        }


        location / {
            proxy_buffering off;
            proxy_pass http://localhost:7776;
        }
    }
}

Chrome 控制台:

任何帮助将不胜感激,谢谢!

将所有 localhost 更改为 127.0.0.1 这解决了我的问题。