如何解决在连接到上游时,nginx docker connect失败110:连接超时,相同的配置在没有docker的情况下也有效,这可能是什么问题?
我有一个来自nginx docker映像nginx:stable
的反向代理。
Dockerfile:
FROM nginx:stable
COPY main.conf /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf
COPY liveness /liveness
RUN chmod +x liveness/liveness_probe.sh
反向代理有时会随机返回502错误的网关,并且在日志中我可以看到:
2020/09/30 10:51:07 [error] 28#28: *67 connect() failed (110: Connection timed out) while connecting to upstream,client: xx.xx.xx.xx,server:,request: "POST xx HTTP/1.1",upstream: "xx",host: "xx"
main.conf:
server {
listen 80;
listen [::]:80;
#Seconds to wait for timeout
# fastcgi_read_timeout 300s;
proxy_buffers 32 4m;
proxy_busy_buffers_size 25m;
proxy_buffer_size 512k;
proxy_ignore_headers "Cache-Control" "Expires";
proxy_max_temp_file_size 0;
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_set_header Connection "";
client_max_body_size 1024m;
client_body_buffer_size 4m;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
proxy_intercept_errors off;
proxy_http_version 1.1;
location ^~ / {
proxy_pass https://xx.com;
}
}
nginx.conf:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
真正奇怪的是,如果我在带有ubuntu 20.04的虚拟机中使用相同的配置并安装nginx软件包(不带docker),则反向代理可以正常工作而不会出现110个随机连接错误...
这可能是什么问题?
一切都在aws中-远在alb入口控制器后面。
要丢弃入口控制器问题,我也暴露在负载均衡器服务中,并且问题仍然存在,因此丢弃所有alb入口控制器问题...
更新:
好吧,所以我刚刚做的另一项测试是在同一个vm中,反向代理正在工作,做了一个docker build和docker run,将它绑定到另一个端口,它不会返回502,这似乎是集成节点的问题Docker容器已排定。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。