收藏
回答

用nginx代理https://api.weixin.qq.com,应用请求超时?

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

回答关注问题邀请回答
收藏

3 个回答

  • 咕天乐。
    咕天乐。
    2023-11-09

    这个问题解决了吗


    2023-11-09
    有用
    回复
  • Gandalf
    Gandalf
    2023-08-21

    找一下你们网络服务商问问,我们也出现了这个问题,最后查到是移动全公司下发工单,说腾讯120.232.65.161 ip有违规行为,移动把这个ip封了

    2023-08-21
    有用
    回复
  • ؞咬了你؞F࿆ū࿆t࿆ū࿆r࿆ē࿆
    ؞咬了你؞F࿆ū࿆t࿆ū࿆r࿆ē࿆
    2022-12-01

    我觉得错误信息说的很明确了……

    proxy_connect_timeout 300,这个超时设大点或者去掉试试呗

    然后,你这个location /wxapi,真的不用rewrite么,这样你请求微信api域名的时候,这个wxapi会带在路径里的吧

    2022-12-01
    有用
    回复 2
    • 华叔
      华叔
      2022-12-01
      proxy_connect_timeout 设置过6000都没用,wxapi不会带在路径里面,调用是有成功的,但是超时的次数更多
      2022-12-01
      回复
    • ؞咬了你؞F࿆ū࿆t࿆ū࿆r࿆ē࿆
      ؞咬了你؞F࿆ū࿆t࿆ū࿆r࿆ē࿆
      2022-12-02回复华叔
      你直接内部通过别的例如curl或者wget一类软件直接往外请求会超时嘛?如果像你描述的那样,我觉得是不是防火墙或者路由的什么配置导致的问题。
      2022-12-02
      回复
登录 后发表内容