Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何使用Angular和NodeJ配置ngnix(代理服务器)?_Node.js_Angular_Sockets_Nginx_Proxy - Fatal编程技术网

Node.js 如何使用Angular和NodeJ配置ngnix(代理服务器)?

Node.js 如何使用Angular和NodeJ配置ngnix(代理服务器)?,node.js,angular,sockets,nginx,proxy,Node.js,Angular,Sockets,Nginx,Proxy,我试图让ngnix与节点和角度一起工作。 此时,我可以访问(服务器API)和(角度)。但是,当我尝试使用socket.io登录时,总是出现“套接字连接超时错误”。我认为这个错误是由于反向代理技术造成的。我是否缺少任何配置文件?还是设置了错误的标题 ngnix形态: server { listen 443 ssl; all centificate letscrypt Stuff location / {

我试图让ngnix与节点角度一起工作。 此时,我可以访问(服务器API)和(角度)。但是,当我尝试使用socket.io登录时,总是出现“套接字连接超时错误”。我认为这个错误是由于反向代理技术造成的。我是否缺少任何配置文件?还是设置了错误的标题

ngnix形态:

server {
        listen              443 ssl;
        all centificate letscrypt Stuff
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://127.0.0.1:4200/;
        }
        location /api/ {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:3030/;
        }
    }

谢谢

在您所在的位置/街区尝试此功能

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

proxy_set_header Host $host;

这有助于我进行相同的配置,但是我没有遇到与您相同的问题。我的套接字连接正常,但出现握手错误,套接字将在轮询时回退。

在您的位置/块中尝试此操作

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

proxy_set_header Host $host;

这有助于我进行相同的配置,但是我没有遇到与您相同的问题。我的套接字连接正常,但出现了握手错误,套接字将在轮询时回退。

我遇到了相同的问题,并解决了在位置/块中添加这些行的问题:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;

但是,您的客户端应连接到服务器,但不包括http://(或https://用于SSL)协议,并且仅使用服务器名或ip地址,或通过指定ws://(或wss://用于SSL)协议,并解决了在位置/块中添加这些行的问题:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
但是,您的客户端应连接到服务器,但不包括http://(或https://用于SSL)协议,并且仅使用服务器名称或ip地址,或通过指定ws://(或wss://用于SSL)协议