nginx代理https://api.weixin.qq.com,nginx配置和error日志如下,应用上发起请求报错[error] 3633#0: *1900 upstream timed out (110: Connection timed out) while connecting to upstream,求大佬指导
nginx配置:
server {
listen 16004;
server_name api.weixin.qq.com;
location /wxapi/ {
proxy_ssl_verify off;
proxy_pass https://api.weixin.qq.com/;
proxy_connect_timeout 300;
proxy_set_header Host $http_host;
index index.html;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header X-Frame-Options SAMEORIGIN;
}
报错:
2022/12/01 15:13:30 [error] 26888#0: *2254 connect() failed (110: Connection timed out) while connecting to upstream, client: 应用IP1, server: api.weixin.qq.com, request: "GET /wxapi/sns/oauth2/access_token?appid=tokenXXX HTTP/1.1", upstream: "https://112.60.20.154:443/sns/oauth2/access_token?appid=tokenXXX ", host: "nginx代理IP2:16004"
域名解析的IP都有超时的情况:
Non-authoritative answer:
Name: api.weixin.qq.com
Address: 120.232.65.161
Name: api.weixin.qq.com
Address: 112.53.42.235
Name: api.weixin.qq.com
Address: 112.60.20.154
这个问题解决了吗
找一下你们网络服务商问问,我们也出现了这个问题,最后查到是移动全公司下发工单,说腾讯120.232.65.161 ip有违规行为,移动把这个ip封了
我觉得错误信息说的很明确了……
proxy_connect_timeout 300,这个超时设大点或者去掉试试呗
然后,你这个location /wxapi,真的不用rewrite么,这样你请求微信api域名的时候,这个wxapi会带在路径里的吧