[英]nginx as reverse proxy for express server 504 Gateway Time-out
[英]NGINX proxy_pass Second Location Block 504 Gateway Time-Out
在服务器上,我有 2 个容器,前端在 8092 端口上运行,后端在 3011 端口上运行。在浏览器中,我可以看到前端,但所有后端调用都得到 504 网关超时。 前端是一个 angular 应用,后端是一个 express nodejs 应用。
后端端点正在调用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 网关超时意味着 NGINX 代理在指定的时间跨度内没有从容器中得到答案。
确保您的后端容器正在运行,并且使用并公开了正确的端口。
如果您的容器没有 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.