公司服务部署在内网,内网服务器无法访问互联网,需要通过可以访问互联网的跳板机才能访问外网,因此我使用nginx在跳板机上做正向代理转发内网对小程序api的请求,由于小程序api只支持https,而nginx转发https请求需要用到ngx_http_proxy_connect模块,下面是我的nginx正向代理相关配置:
server {
# 正向代理
listen 8088; # 这个端口可以自己设随便设置
resolver 114.114.114.114 ipv6=off; # 这个是DNS 服务器地地址
proxy_connect;
proxy_connect_allow all;
proxy_connect_connect_timeout 10s;
proxy_connect_read_timeout 10s;
proxy_connect_send_timeout 10s;
access_log logs/http_proxy.access.log;
error_log logs/http_proxy.error.log;
location / {
proxy_pass $scheme://$http_host$request_uri;
}
}
这样设置以后,转发是没问题的,但是偶尔会出现转发超时,查看nginx正向代理access.log日志,打印的提示信息为:
"CONNECT api.weixin.qq.com:443 HTTP/1.1" 502 150 "-" "Apache-HttpClient/4.5.14 (Java/1.8.0_202)"
查看nginx error.log日志,打印的错误信息为:
[error] 108182#0: *3004341 proxy_connect: upstream read timed out (peer:116.128.184.169:443) while connecting to upstream, client: 122.231.177.224, server: , request: "CONNECT api.weixin.qq.com:443 HTTP/1.1", host: "api.weixin.qq.com"
网上查了很多资料,都找不到解决办法,请问下大神们,有遇到过同样的问题吗?咋解决的?

把超时时间再设置大点呢,15S
https://stackoverflow.com/questions/18740635/nginx-upstream-timed-out-110-connection-timed-out-while-reading-response-hea