ngx_http_proxy_connect_module icon indicating copy to clipboard operation
ngx_http_proxy_connect_module copied to clipboard

proxy_connect: client read timed out while connecting to upstream

Open koalabearguo opened this issue 4 years ago • 7 comments

how can I reslove this problem?

in log file,there are a lot of this txt,but i can connect the nginx ,the http tunnel works well,i can brower google,youtube...

i want to change some parameters,but failed.

so how to fix this,thanks.

nginx/1.16.1

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
error_log /var/log/nginx/debug.log debug;
pid /run/nginx.pid;


include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}
http {
server {
    listen      127.0.0.1:80;
    server_name  localhost;
    resolver       127.0.0.1 ipv6=off;
    resolver_timeout 5s;

    # forward proxy for CONNECT request
    proxy_connect;
    proxy_connect_allow            all;
    proxy_connect_connect_timeout  600s;
    proxy_connect_read_timeout     600s;
    proxy_connect_send_timeout     600s;

    proxy_connect_timeout 600s;
    proxy_send_timeout 600s;
    proxy_read_timeout 600s;
    send_timeout 600s;

    #include conf.d/ip_allow.ini;
    #auth_basic  "secret";   #添加此配置
    #auth_basic_user_file  /etc/squid/passwd; #加载生成的密码文件

    # forward proxy for non-CONNECT request
    location / {
	    #proxy_pass http://127.0.0.1:3128;
	    # these two lines here            
            #proxy_http_version 1.1;
            #proxy_set_header Connection "";

	    proxy_pass http://$http_host;
            proxy_set_header Host $host:$http_host;
    }
}
}

2021/04/15 02:35:17 [error] 964#0: *137 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT adservice.google.com:443 HTTP/1.1", host: "adservice.google.com:443" 2021/04/15 02:35:17 [error] 964#0: *127 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT www.google.com:443 HTTP/1.1", host: "www.google.com:443" 2021/04/15 02:35:18 [error] 965#0: *153 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT github.com:443 HTTP/1.1", host: "github.com:443" 2021/04/15 02:35:20 [error] 965#0: *161 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT github.githubassets.com:443 HTTP/1.1", host: "github.githubassets.com:443" 2021/04/15 02:35:20 [error] 965#0: *155 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT github.githubassets.com:443 HTTP/1.1", host: "github.githubassets.com:443" 2021/04/15 02:35:22 [error] 964#0: *141 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT ogs.google.com:443 HTTP/1.1", host: "ogs.google.com:443" 2021/04/15 02:35:22 [error] 964#0: *45 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT play.google.com:443 HTTP/1.1", host: "play.google.com:443" 2021/04/15 02:35:23 [error] 964#0: *147 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT github.githubassets.com:443 HTTP/1.1", host: "github.githubassets.com:443" 2021/04/15 02:35:27 [error] 965#0: *111 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:35:27 [error] 965#0: *169 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT google.com:443 HTTP/1.1", host: "google.com:443" 2021/04/15 02:35:27 [error] 964#0: *167 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT google.com:443 HTTP/1.1", host: "google.com:443" 2021/04/15 02:35:47 [error] 964#0: *173 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT content-autofill.googleapis.com:443 HTTP/1.1", host: "content-autofill.googleapis.com:443" 2021/04/15 02:35:47 [error] 965#0: *171 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT content-autofill.googleapis.com:443 HTTP/1.1", host: "content-autofill.googleapis.com:443" 2021/04/15 02:37:08 [error] 965#0: *181 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT content-autofill.googleapis.com:443 HTTP/1.1", host: "content-autofill.googleapis.com:443" 2021/04/15 02:37:08 [error] 964#0: *179 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT content-autofill.googleapis.com:443 HTTP/1.1", host: "content-autofill.googleapis.com:443" 2021/04/15 02:37:20 [error] 965#0: *149 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT avatars.githubusercontent.com:443 HTTP/1.1", host: "avatars.githubusercontent.com:443" 2021/04/15 02:37:20 [error] 964#0: *185 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:37:20 [error] 965#0: *183 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:38:25 [error] 964#0: *191 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:38:53 [error] 965#0: *195 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT avatars.githubusercontent.com:443 HTTP/1.1", host: "avatars.githubusercontent.com:443" 2021/04/15 02:39:03 [error] 964#0: *193 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT avatars.githubusercontent.com:443 HTTP/1.1", host: "avatars.githubusercontent.com:443" 2021/04/15 02:39:21 [error] 964#0: *151 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT github.com:443 HTTP/1.1", host: "github.com:443" 2021/04/15 02:40:24 [error] 964#0: *199 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT play.google.com:443 HTTP/1.1", host: "play.google.com:443" 2021/04/15 02:40:24 [error] 965#0: *187 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:40:24 [error] 965#0: *197 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT play.google.com:443 HTTP/1.1", host: "play.google.com:443" 2021/04/15 02:41:27 [error] 965#0: *205 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:41:27 [error] 964#0: *202 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:44:28 [error] 964#0: *209 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:44:28 [error] 965#0: *207 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:45:32 [error] 964#0: *211 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443" 2021/04/15 02:45:32 [error] 965#0: *213 proxy_connect: client read timed out while connecting to upstream, client: 127.0.0.1, server: localhost, request: "CONNECT beacons.gcp.gvt2.com:443 HTTP/1.1", host: "beacons.gcp.gvt2.com:443"

koalabearguo avatar Apr 15 '21 07:04 koalabearguo

ok,I have tried to change the below parameter,it is working well... I think the HTTP tunnel should be keep-alive although client do not read from tunnel ;nginx did not process CONNECT method well for the client

client_body_timeout  3600s;

koalabearguo avatar Apr 16 '21 04:04 koalabearguo

ok,I have tried to change the below parameter,it is working well... I think the HTTP tunnel should be keep-alive although client do not read from tunnel ;nginx did not process CONNECT method well for the client

client_body_timeout  3600s;

Hello, I encountered a similar problem, and I solved it through the configuration you gave. But at the same time, a new problem appeared. When the access log records the request, there is a delay of more than 1 minute. Is there any problem with this, or will it affect the performance of nginx? Looking forward to your answers.

sbadyjy avatar May 06 '21 11:05 sbadyjy

proxy_pass http://$http_host does not support keep-alive; you have to use a named upstream {} and uncomment both proxy_set_header Connection "" & proxy_http_version 1.1;

the timeout you changed and timestamps referenced suggest that your connection to those hosts is slow; you can change your log format to include upstream timings and see where the issue is

On Thu, May 6, 2021 at 2:05 PM sbadyjy @.***> wrote:

ok,I have tried to change the below parameter,it is working well... I think the HTTP tunnel should be keep-alive although client do not read from tunnel ;nginx did not process CONNECT method well for the client

client_body_timeout 3600s;

Hello, I encountered a similar problem https://github.com/chobits/ngx_http_proxy_connect_module/issues/191, and I solved it through the configuration you gave. But at the same time, a new problem appeared. When the access log records the request, there is a delay of more than 1 minute. Is there any problem with this, or will it affect the performance of nginx? Looking forward to your answers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chobits/ngx_http_proxy_connect_module/issues/189#issuecomment-833436481, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6DR6BBMGNTOI67LUQCFDLTMJZWRANCNFSM4263PYTA .

AndreiG6 avatar May 06 '21 19:05 AndreiG6

I forgot to mention, you might want to look into lua & dynamic upstreams

On Thu, May 6, 2021 at 10:46 PM Andrei @.***> wrote:

proxy_pass http://$http_host does not support keep-alive; you have to use a named upstream {} and uncomment both proxy_set_header Connection "" & proxy_http_version 1.1;

the timeout you changed and timestamps referenced suggest that your connection to those hosts is slow; you can change your log format to include upstream timings and see where the issue is

On Thu, May 6, 2021 at 2:05 PM sbadyjy @.***> wrote:

ok,I have tried to change the below parameter,it is working well... I think the HTTP tunnel should be keep-alive although client do not read from tunnel ;nginx did not process CONNECT method well for the client

client_body_timeout 3600s;

Hello, I encountered a similar problem https://github.com/chobits/ngx_http_proxy_connect_module/issues/191, and I solved it through the configuration you gave. But at the same time, a new problem appeared. When the access log records the request, there is a delay of more than 1 minute. Is there any problem with this, or will it affect the performance of nginx? Looking forward to your answers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chobits/ngx_http_proxy_connect_module/issues/189#issuecomment-833436481, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6DR6BBMGNTOI67LUQCFDLTMJZWRANCNFSM4263PYTA .

AndreiG6 avatar May 06 '21 19:05 AndreiG6

client_body_timeout 3600s;

This help me fix connection timeout

sergey-safarov avatar Jun 29 '21 08:06 sergey-safarov

Link to https://github.com/chobits/ngx_http_proxy_connect_module/issues/175.

Similar issue.

I have understood the problem, but I need to consider how to set right timer and some new instructions or variables. Here, the timer setting have some works and needs more testing.

chobits avatar Jul 03 '21 04:07 chobits

@chobits when bugfix this

qingdaofu avatar Oct 26 '21 08:10 qingdaofu

I fixed a bug that orignal proxy_connect_read_timeout not work recently

More details see here: https://github.com/chobits/ngx_http_proxy_connect_module/pull/249#issue-1463336830

chobits avatar Nov 29 '22 09:11 chobits