nginx正向代理连接不稳定,经常抛出502

1、环境:我使用nginx正向代理内网的服务器,内网应用访问nginx对应端口的时候,转发至企微的这个域名: https://qyapi.weixin.qq.com,内网应用为http协议。容器为tomcat。 https://qyapi.weixin.qq.xn--com%2Chttp-0g0m25ydjf824b4l5dmz3ax02b.xn--tomcat-vy7il27c7il./
内网tomcat应用 ——> nginx正向代理 ——> 企微
nginx服务器没有安装PHP,所以不用考虑修改PHP的相关参数配置。
2、现象:正向代理某些时候可以连通(内网服务器上curl 代理ip 端口 可以通),有些时候不能通,通和不通的时间几乎五五开,相同的配置,没有修改任何东西。
不通的时候,curl返回502
img
对应nginx日志中抛错: failed (110: Connection timed out) while connecting to upstream
img
3、防火墙已永久关闭,不通的时候应用服务器和代理服务器telnet是可以通的,网络层应该没问题。
4、附上我的nginx配置:


```xml
#user  root; 
worker_processes  auto; 
#worker_cpu_affinity  auto; 
 
error_log  logs/error.log debug; 
#error_log  logs/error.log  notice; 
#error_log  logs/error.log  info; 
#pid        logs/nginx.pid; 
 
events { 
    worker_connections  1024; 
} 
http { 
    include       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" $upstream_addr';                  
    #access_log  off; 
    access_log  logs/access.log  main; 
    sendfile        on; 
    #tcp_nopush     on; 
    #gzip  on; 
    #gzip_disable "MSIE [1-6]."; 
    client_header_buffer_size    512k; 
    large_client_header_buffers  4 512k; 
    client_max_body_size 100M;
        keepalive_timeout  65s; 
        types_hash_max_size 2048; 
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 8 128k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
        proxy_connect_timeout    300;
        proxy_read_timeout       300;
        proxy_send_timeout       300; 
        #正向代理
        server { 
                listen 38888; 
                server_name 10.202.66.24; 
                location / { 
                proxy_redirect off; 
                proxy_pass https://qyapi.weixin.qq.com; 
                #proxy_ssl_server_name on;
                } 
                location = /favicon.ico { 
                        log_not_found off; 
                } 
        } 
}

```

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^