简体   繁体   English

NGINX proxy_pass 第二个位置块 504 网关超时

[英]NGINX proxy_pass Second Location Block 504 Gateway Time-Out

On a server, I have 2 containers, the frontend running on port 8092 and the backend on port 3011. In a browser, I can see the frontend, but all the backend calls are getting a 504 Gateway Time-out.在服务器上,我有 2 个容器,前端在 8092 端口上运行,后端在 3011 端口上运行。在浏览器中,我可以看到前端,但所有后端调用都得到 504 网关超时。 The frontend is an angular app, and the backend is an express nodejs app.前端是一个 angular 应用,后端是一个 express nodejs 应用。

the backend endpoints are calling https://test.example.com/api/some-path If I go to https://xxx.domain.local:3011/api/some-path I get a response.后端端点正在调用https://test.example.com/api/some-path如果我从 go 到Z5E056C500A1C4B6A7110B50D807BADE15Z//0some-path Ilocal:响应。

server {
    listen 443 ssl;
    server_name test.example.com;

    ssl_certificate /etc/ssl/certs/example.crt;
    ssl_certificate_key /etc/ssl/private/web.key;

    location / {
        proxy_pass http://xxx.domain.local:8092;
        proxy_set_header Host $host;
        proxy_set_header X-Real_IP $remote_addr;
    }

    location /api {
        proxy_pass https://xxx.domain.local:3011;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

504 Gateway Time-out means the NGINX proxy didn't get an answer from the container within a specified timespan. 504 网关超时意味着 NGINX 代理在指定的时间跨度内没有从容器中得到答案。

Make sure that your backend container is running and the correct port is used and exposed.确保您的后端容器正在运行,并且使用并公开了正确的端口。

Also make sure you are using http and not https if your container doesn't have a ssl certificate.如果您的容器没有 ssl 证书,还要确保您使用的是 http 而不是 https。

location /api {
        proxy_pass http://xxx.domain.local:3011;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM