# Nginx forward prxoy problem when header contains 'Proxy-Connection: keep-alive'

**URL:** <https://www.ruby-forum.com/t/nginx-forward-prxoy-problem-when-header-contains-proxy-connection-keep-alive/190476>\
**Category:** NGINX\
**Created:** [June 21, 2010, 10:09am UTC](https://www.ruby-forum.com/t/nginx-forward-prxoy-problem-when-header-contains-proxy-connection-keep-alive/190476 "2010-06-21T10:09:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xuzheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/94ad74/32.png) [@xuzheng](https://www.ruby-forum.com/u/xuzheng)\
**Post date:** [June 21, 2010, 10:09am UTC](https://www.ruby-forum.com/t/nginx-forward-prxoy-problem-when-header-contains-proxy-connection-keep-alive/190476/1 "2010-06-21T10:09:21Z")

</div>

hi, when i use nginx as a forward prxoy, some page can not be downloaded  
successfully.  
example:  
http\_proxy=ip:port wget -O test.html  
[http://s1.ganjistatic1.com/css/base\_ue3\_house.\_\_1276756225\_\_.css--header='Proxy-Connection:](http://s1.ganjistatic1.com/css/base_ue3_house. __1276756225__.css--header='Proxy-Connection:)  
keep-alive’ -S  
the received data length always less than response heade specificed  
length,  
so wget will retry again and again.  
if use ie or firefox, the page load very slow, I guess the browser retry  
many times like wget.  
but if not sent header ‘Proxy-Connection: keep-alive’, the page can be  
downloaded successfully.  
Any one has idea?  
thanks.

the nginx config file:  
server { # simple load balancing  
listen 9681;  
resolver 202.106.0.20;  
location / {  
proxy\_pass http://$http\_host$request\_uri;  
}  
}

the nginx version is 0.7.65-5 ,  
os is debian Linux dev 2.6.30-1-amd64

---

<div class="post-metadata">

**Author:** ![xuzheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/94ad74/32.png) [@xuzheng](https://www.ruby-forum.com/u/xuzheng)\
**Post date:** [June 21, 2010, 10:22am UTC](https://www.ruby-forum.com/t/nginx-forward-prxoy-problem-when-header-contains-proxy-connection-keep-alive/190476/2 "2010-06-21T10:22:49Z")

</div>

Hello!

On Mon, Jun 21, 2010 at 04:08:25PM +0800, xuzheng wrote:

> hi, when i use nginx as a forward prxoy, some page can not be downloaded  
> successfully.

nginx isn’t forward proxy, and it know nothing about  
Proxy-Connection. If server you are connecting to happens to keep  
connection alive due to “Proxy-Connection: keep-alive” header -  
the behaviour you see is quite expected.

You have to manually remove this header from request via something  
like

```
proxy_set_header Proxy-Connection "";

```

Or, much better, just don’t use nginx as forward proxy.

Maxim D.

---

<div class="post-metadata">

**Author:** ![xuzheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/94ad74/32.png) [@xuzheng](https://www.ruby-forum.com/u/xuzheng)\
**Post date:** [June 21, 2010, 10:29am UTC](https://www.ruby-forum.com/t/nginx-forward-prxoy-problem-when-header-contains-proxy-connection-keep-alive/190476/3 "2010-06-21T10:29:16Z")

</div>

xuzheng at 2010-6-21 16:08 wrote:

> but if not sent header ‘Proxy-Connection: keep-alive’, the page can be  
> downloaded successfully.  
> Any one has idea?  
> Nginx does not support keepalive connection with backend server.

Maybe you should remove the header of “proxy-connection” like this:

proxy\_set\_header Proxy-Connection “”;

> 

–  
Weibin Y.

---

<div class="post-metadata">

**Author:** ![xuzheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/94ad74/32.png) [@xuzheng](https://www.ruby-forum.com/u/xuzheng)\
**Post date:** [June 21, 2010, 11:10am UTC](https://www.ruby-forum.com/t/nginx-forward-prxoy-problem-when-header-contains-proxy-connection-keep-alive/190476/4 "2010-06-21T11:10:15Z")

</div>

thanks, after remove the header, it works well.

2010/6/21 Weibin Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![xuzheng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/94ad74/32.png) [@xuzheng](https://www.ruby-forum.com/u/xuzheng)\
**Post date:** [June 21, 2010, 6:11pm UTC](https://www.ruby-forum.com/t/nginx-forward-prxoy-problem-when-header-contains-proxy-connection-keep-alive/190476/5 "2010-06-21T18:11:12Z")

</div>

thanksï¼ŒMaxim D. 🙂  
I must use your remove-header way, because I am building a test env like  
online, for example,  
when tester visits our site page( same to online url )with proxy, nginx  
forward to test machine,  
but when he visits outer-site page ,nginx forward to outer.  
other forward proxy such as squid doesn’t seems to have such feature.  
Indeed, in this case ,this nginx is a forward-reverse proxy.

2010/6/21 Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
