如何使用 Nginx 和 Docker 代理应用程序



我在nginx上遇到5#5: *23 upstream timed out (110: Connection timed out) while connecting to upstream, client:错误。

我已经阅读并应用了导致 504 网关超时问题的 Nginx 反向代理。但是,我的情况略有不同,因为我有三个端点要代理。

我的 nginx.conf:

worker_processes 1;
events { worker_connections 1024; }
http {
server {
listen       80;
listen       [::]:80;
server_name  rollcall;
location /api {
proxy_set_header   X-Real-IP $remote_addr;
proxy_set_header   Host      $http_host;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass "http://[hostip]:8080/api";
}
location /api/attendance {
proxy_set_header   X-Real-IP $remote_addr;
proxy_set_header   Host      $http_host;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass "http://[hostip]:8000/api";
}
location / {
include /etc/nginx/mime.types;
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;

}
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   /usr/share/nginx/html;
}

}
}

我的"/"和带有端口:8080代理的应用程序符合预期,但是我的端口:8000的应用程序没有代理,并得到上面提到的超时异常。如果我尝试使用端口:8000请求应用程序,则应用程序将按预期工作。

什么可能导致上述超时,以及我应该如何更改我的 conf 文件?

问题不是与Nginx或Docker相关的问题。端口 8000 未在应用程序快捷批处理上打开。

最新更新