Welcome! Log In Create A New Profile

Advanced

Re: How to make nginx establish persistent connections with squid?

Maxim Dounin
March 22, 2013 05:54AM
Hello!

On Fri, Mar 22, 2013 at 05:25:15AM -0400, selphon wrote:

> hi,
> I use nginx as load balance and forward request to squid use http/1.1, the
> topology is below:
>
> chrome ---> nginx(:80) ---> squid(:8080) ---> origin server(nginx :80)
>
> the nginx configuration:
> upstream backend {
> server 192.168.13.210:80;
> keepalive 10;
> }
>
>
> server {
> listen 80 default;
> server_name _;
>
> proxy_set_header Host $host;
>
> proxy_http_version 1.1;
> proxy_set_header Connection "";
>
> location / {
> proxy_pass http://backend;
> }
> }
>
> the squid configuration of persistent connections is supported on both
> client side and server side:
> ##########timeout##########
> client_persistent_connections on
> server_persistent_connections on
>
> request_timeout 240 seconds #to client/wait client's request
> client_lifetime 240 seconds #to client/all request time
> persistent_request_timeout 30 seconds #to client/keepalive
> pconn_timeout 30 seconds #to origin server or peer/keepalive
> connect_timeout 240 seconds #to origin server/only connect
> read_timeout 240 seconds #to origin server or peer/wait recv data
>
> Then, I made 5 requests such as 'http://test.cache.com/p3.jpg?tt=2013032206'
> and could not find any persistent connection between nginx and squid.
>
> the squid log show:
> 127.0.0.1 - - [22/Mar/2013:16:12:06 +0800] "GET
> http://test.cache.com/p3.jpg?tt=2013032205 HTTP/1.1" 304 364
> "http://test.cache.com/p3.jpg?tt=2013032205" "Mozilla/5.0 (Windows NT 6.1)
> AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22"
> TCP_REFRESH_HIT:DIRECT/192.168.13.210 0
>
> "Host: test.cache.com #request header
> Cache-Control: max-age=0
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.22 (KHTML, like
> Gecko) Chrome/25.0.1364.172 Safari/537.22
> Referer: http://test.cache.com/p3.jpg?tt=2013032205
> Accept-Encoding: gzip,deflate,sdch
> Accept-Language: zh-CN,zh;q=0.8
> Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3
> If-Modified-Since: Tue, 23 Oct 2012 04:07:19 GMT"
>
> "HTTP/1.0 304 Not Modified #response header
> Server: nginx/1.2.6
> Date: Fri, 22 Mar 2013 08:12:06 GMT
> Last-Modified: Tue, 23 Oct 2012 04:07:19 GMT
> Expires: Fri, 22 Mar 2013 10:12:06 GMT
> Cache-Control: max-age=7200
> X-Cache: MISS from vm-linux1.test.com
> X-Cache-Lookup: HIT from vm-linux1.test.com:8080
> Via: 1.1 vm-linux1.test.com:8080 (squid/2.7.STABLE9)
> Connection: close"
>
> as we see(last line), squid announced the Connection should be close after
> the request. I think this is why nginx couldn't make a persistent connection
> with squid.
>
> then I try to set: proxy_set_header Connection "keep-alive"; forcing that
> the request must be keep-alive.
> the request and response is:
>
> 127.0.0.1 - - [22/Mar/2013:15:59:09 +0800] "GET
> http://test.cache.com/p3.jpg?tt=2013032203 HTTP/1.1" 304 369
> "http://test.cache.com/p3.jpg?tt=2013032203" "Mozilla/5.0 (Windows NT 6.1)
> AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22"
> TCP_REFRESH_HIT:DIRECT/192.168.13.210 0
>
> "Host: test.cache.com
> Connection: keep-alive
> Cache-Control: max-age=0
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.22 (KHTML, like
> Gecko) Chrome/25.0.1364.172 Safari/537.22
> Referer: http://test.cache.com/p3.jpg?tt=2013032203
> Accept-Encoding: gzip,deflate,sdch
> Accept-Language: zh-CN,zh;q=0.8
> Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3
> If-Modified-Since: Tue, 23 Oct 2012 04:07:19 GMT"
>
> "HTTP/1.0 304 Not Modified
> Server: nginx/1.2.6
> Date: Fri, 22 Mar 2013 07:59:09 GMT
> Last-Modified: Tue, 23 Oct 2012 04:07:19 GMT
> Expires: Fri, 22 Mar 2013 09:59:09 GMT
> Cache-Control: max-age=7200
> X-Cache: MISS from vm-linux1.test.com
> X-Cache-Lookup: HIT from vm-linux1.test.com:8080
> Via: 1.1 vm-linux1.test.com:8080 (squid/2.7.STABLE9)
> Connection: keep-alive"
>
> though the Connection of response is keep-alive, nginx still didn't make any
> persistent connection with squid.
>
> Is there any way to configure nginx use a persistent connection where
> forward requests to squid ? help help
>
> nginx_version: 1.2.6
> squid_version: 2.7.STABLE9

Connections are kept alive only if a response is in HTTP/1.1
protocol.

--
Maxim Dounin
http://nginx.org/en/donation.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
SubjectAuthorPosted

How to make nginx establish persistent connections with squid?

selphonMarch 22, 2013 05:25AM

Re: How to make nginx establish persistent connections with squid?

Maxim DouninMarch 22, 2013 05:54AM

Re: How to make nginx establish persistent connections with squid?

selphonMarch 24, 2013 04:30AM

Re: How to make nginx establish persistent connections with squid?

selphonMarch 24, 2013 04:42AM

Re: How to make nginx establish persistent connections with squid?

Maxim DouninMarch 25, 2013 07:28AM

Re: How to make nginx establish persistent connections with squid?

selphonMarch 28, 2013 05:04AM

RE: How to make nginx establish persistent connections with squid?

Lukas TribusMarch 28, 2013 01:40PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 87
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 184 on July 08, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready