Py学习  »  NGINX

如何使用Nginx配置Express

Aref Aslani amin_2c • 4 年前 • 350 次点击  

我已经根据 this 文章。

这是我的Nginx配置:

server {
    access_log /var/log/nginx/access.log upstream_time;

    listen 8080;
    server_name _;

    location / {
        # default port, could be changed if you use next with custom server
        proxy_pass http://localhost:4000;

        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;
    }
}

我通过Nginx发送给Node应用程序的第一个请求是可以的,但是之后,任何请求都需要60秒才能响应。这是日志:

192.168.13.27 - - [20/Feb/2019:09:16:01 +0100] "GET / HTTP/1.1" 200 302276 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"rt=0.324 uct="0.000" uht="0.002" urt="0.002"
192.168.13.27 - - [20/Feb/2019:09:17:04 +0100] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"rt=60.003 uct="0.000, 0.000" uht="60.002, 0.001" urt="60.002, 0.001"

如果我直接请求端口4000上的节点应用程序,一切正常。

我已经搜索了StAcExpRoad以进一步查看,但问题仍然存在。我试着降低 proxy_read_timeout proxy_connect_timeout 值,但它只在Express中指定的静态文件上工作 static 模块和其他快速路由抛出504网关超时错误。我怎样才能找到并解决这个问题?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/52843
 
350 次点击