# Nginx keeps passing the same http\_cookie to uwsgi

**URL:** <https://www.ruby-forum.com/t/nginx-keeps-passing-the-same-http-cookie-to-uwsgi/220735>\
**Category:** NGINX\
**Created:** [June 19, 2012, 1:27am UTC](https://www.ruby-forum.com/t/nginx-keeps-passing-the-same-http-cookie-to-uwsgi/220735 "2012-06-19T01:27:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 19, 2012, 1:27am UTC](https://www.ruby-forum.com/t/nginx-keeps-passing-the-same-http-cookie-to-uwsgi/220735/1 "2012-06-19T01:27:35Z")

</div>

I have a small python app running via uwsgi with requests served by  
nginx.

I’m printing the environment variables… and it looks like after a  
couple of ok requests, nginx is sending the same HTTP\_COOKIE param for  
unrelated requests:

For example:  
{‘UWSGI\_CHDIR’: ‘/ebs/py’, ‘HTTP\_COOKIE’:  
‘ge\_t\_c=4fcee8450c3bee709800920c’, ‘UWSGI\_SCRIPT’: ‘server’,  
‘uwsgi.version’: ‘1.1.2’, ‘REQUEST\_METHOD’: ‘GET’, ‘PATH\_INFO’:  
‘/redirect/ebebaf3b-475a-4010-9a72-96eeff797f1e’, ‘SERVER\_PROTOCOL’:  
‘HTTP/1.1’, ‘QUERY\_STRING’: ‘’, ‘x-wsgiorg.fdevent.readable’: , ‘CONTENT\_LENGTH’: ‘’, ‘uwsgi.ready\_fd’:  
None, ‘HTTP\_USER\_AGENT’: ‘Mozilla/5.0 (compatible; MSIE 9.0; Windows NT  
6.1; WOW64; Trident/5.0)’, ‘HTTP\_CONNECTION’: ‘close’, ‘HTTP\_REFERER’:  
‘[http://www.facebook.com/](http://www.facebook.com/)’, ‘SERVER\_NAME’: ‘[pixel.domain.com](http://pixel.domain.com)’,  
‘REMOTE\_ADDR’: ‘10.load.bal.ip’, ‘wsgi.url\_scheme’: ‘http’,  
‘SERVER\_PORT’: ‘80’, ‘wsgi.multiprocess’: True, ‘uwsgi.node’:  
‘[py.domain.com](http://py.domain.com)’, ‘DOCUMENT\_ROOT’: ‘/etc/nginx/html’, ‘UWSGI\_PYHOME’:  
‘/ebs/py’, ‘uwsgi.core’: 127, ‘HTTP\_X\_FORWARDED\_PROTO’: ‘http’,  
‘x-wsgiorg.fdevent.writable’: ,  
‘wsgi.input’:  
\<newrelic.api.web\_transaction.WSGIInputWrapper object at 0x1809b90\>,  
‘HTTP\_HOST’: ‘[track.domain.com](http://track.domain.com)’, ‘wsgi.multithread’: False,  
‘REQUEST\_URI’: ‘/redirect/ebebaf3b-475a-4010-9a72-96eeff797f1e’,  
‘HTTP\_ACCEPT’: ‘text/html, application/xhtml+xml, _/_’, ‘wsgi.version’:  
(1, 0), ‘x-wsgiorg.fdevent.timeout’: None, ‘HTTP\_X\_FORWARDED\_FOR’:  
‘10.load.bal.ip’, ‘wsgi.errors’: \<open file ‘wsgi\_errors’, mode ‘w’ at  
0x1995390\>, ‘REMOTE\_PORT’: ‘36462’, ‘HTTP\_ACCEPT\_LANGUAGE’: ‘en-US’,  
‘wsgi.run\_once’: False, ‘HTTP\_X\_FORWARDED\_PORT’: ‘80’, ‘CONTENT\_TYPE’:  
‘’, ‘wsgi.file\_wrapper’: ,  
‘HTTP\_ACCEPT\_ENCODING’: ‘gzip, deflate’}

and

{‘UWSGI\_CHDIR’: ‘/ebs/py’,  
‘HTTP\_COOKIE’:‘ge\_t\_c=4fcee8450c3bee709800920c’, ‘UWSGI\_SCRIPT’:  
‘server’,‘uwsgi.version’: ‘1.1.2’,‘REQUEST\_METHOD’: ‘GET’,  
‘PATH\_INFO’:‘/redirect/2391e658-95ef-4300-80f5-83dbb1a0e526’,  
‘SERVER\_PROTOCOL’:‘HTTP/1.1’, ‘QUERY\_STRING’: ‘’,  
‘x-wsgiorg.fdevent.readable’:,  
‘CONTENT\_LENGTH’: ‘’,‘uwsgi.ready\_fd’: None, ‘HTTP\_USER\_AGENT’:  
‘Mozilla/5.0 (iPad; CPU OS5\_1\_1 like Mac OS X) AppleWebKit/534.46  
(KHTML, like Gecko)Version/5.1 Mobile/9B206 Safari/7534.48.3’,  
‘HTTP\_CONNECTION’:  
‘close’, ‘HTTP\_REFERER’: ‘[http://www.facebook.com/](http://www.facebook.com/)’,  
‘SERVER\_NAME’:‘[pixel.domain.com](http://pixel.domain.com)’, ‘REMOTE\_ADDR’: ‘10.load.balancer.ip’,  
‘wsgi.url\_scheme’: ‘http’, ‘SERVER\_PORT’: ‘80’,  
‘wsgi.multiprocess’:True, ‘uwsgi.node’: ‘[py.domain.com](http://py.domain.com)’,  
‘DOCUMENT\_ROOT’:  
‘/etc/nginx/html’, ‘UWSGI\_PYHOME’: ‘/ebs/py’, ‘uwsgi.core’:  
127,‘HTTP\_X\_FORWARDED\_PROTO’: ‘http’, ‘x-wsgiorg.fdevent.writable’:  
,  
‘wsgi.input’:\<newrelic.api.web\_transaction.WSGIInputWrapper object at  
0x18f3850\>,‘HTTP\_HOST’: ‘[fire.domain.com](http://fire.domain.com)’, ‘wsgi.multithread’:  
False,‘REQUEST\_URI’: ‘/redirect/2391e658-95ef-4300-80f5-83dbb1a0e526’,  
‘HTTP\_ACCEPT’:‘text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8’,‘wsgi.version’:  
(1, 0), ‘x-wsgiorg.fdevent.timeout’: None,  
‘HTTP\_X\_FORWARDED\_FOR’: ‘10.load.bal.ip’, ‘wsgi.errors’: \<open  
file’wsgi\_errors’, mode ‘w’ at 0x1796e40\>, ‘REMOTE\_PORT’: ‘39498’,  
‘HTTP\_ACCEPT\_LANGUAGE’: ‘en-us’, ‘wsgi.run\_once’:  
False,‘HTTP\_X\_FORWARDED\_PORT’: ‘80’, ‘CONTENT\_TYPE’:  
‘’,‘wsgi.file\_wrapper’: ,‘HTTP\_ACCEPT\_ENCODING’: ‘gzip, deflate’}

These are 2 distinct clients. I opened an incognito session, confirmed  
that no cookie was sent in the headers, and the uwsgi log shows that it  
received the same HTTP\_COOKIE.

How can I make sure that nginx only passes the proper information for  
the current request, without regard to other requests?

---

<div class="post-metadata">

**Author:** ![jeff\_thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ee59a6/32.png) [@jeff\_thomas](https://www.ruby-forum.com/u/jeff_thomas)\
**Post date:** [June 19, 2012, 1:34am UTC](https://www.ruby-forum.com/t/nginx-keeps-passing-the-same-http-cookie-to-uwsgi/220735/2 "2012-06-19T01:34:36Z")

</div>

Another request in a completely fresh browser:

Request Headers:  
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8  
Accept-Charset:ISO-8859-1,utf-8;q=0.7,\*;q=0.3  
Accept-Encoding:gzip,deflate,sdch  
Accept-Language:en-US,en;q=0.8  
Connection:keep-alive  
Host:fire.domain.com  
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_7\_4)  
AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5

uwsgi output of the environment:  
{‘UWSGI\_CHDIR’: ‘/ebs/py’, ‘HTTP\_X\_WAP\_PROFILE’:  
‘[http://uaprof.vtext.com/mot/a956/a956.xml](http://uaprof.vtext.com/mot/a956/a956.xml)’, ‘HTTP\_REFERER’:  
‘[http://www.facebook.com/](http://www.facebook.com/)’, ‘UWSGI\_SCRIPT’: ‘server’, ‘uwsgi.version’:  
‘1.1.2’, ‘REQUEST\_METHOD’: ‘GET’, ‘PATH\_INFO’:  
‘/redirect/8ddcc113-092e-46ce-845b-462b825ea792’, ‘SERVER\_PROTOCOL’:  
‘HTTP/1.1’, ‘QUERY\_STRING’: ‘’, ‘x-wsgiorg.fdevent.readable’: , ‘CONTENT\_LENGTH’: ‘’, ‘uwsgi.ready\_fd’:  
None, ‘HTTP\_USER\_AGENT’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_7\_4)  
AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5’,  
‘HTTP\_CONNECTION’: ‘close’, ‘HTTP\_COOKIE’:  
‘ge\_t\_c=4fcee8450c3bee709800920c’, ‘SERVER\_NAME’: ‘[pixel.domain.com](http://pixel.domain.com)’,  
‘REMOTE\_ADDR’: ‘10.load.bal.ip’, ‘HTTP\_X\_BLUECOAT\_VIA’:  
‘442C08A7416C4033’, ‘wsgi.url\_scheme’: ‘http’, ‘SERVER\_PORT’: ‘80’,  
‘wsgi.multiprocess’: True, ‘uwsgi.node’: ‘[pyfire-1.domain.com](http://pyfire-1.domain.com)’,  
‘DOCUMENT\_ROOT’: ‘/etc/nginx/html’, ‘UWSGI\_PYHOME’: ‘/ebs/py’,  
‘HTTP\_ACCEPT\_CHARSET’: ‘ISO-8859-1,utf-8;q=0.7,_;q=0.3’, ‘uwsgi.core’:  
127, ‘HTTP\_X\_FORWARDED\_PROTO’: ‘http’, ‘x-wsgiorg.fdevent.writable’:  
, ‘wsgi.input’:  
\<newrelic.api.web\_transaction.WSGIInputWrapper object at 0x17df650\>,  
‘HTTP\_HOST’: ‘[fire.domain.com](http://fire.domain.com)’, ‘wsgi.multithread’: False,  
‘HTTP\_UA\_CPU’: ‘AMD64’, ‘HTTP\_CACHE\_CONTROL’: ‘max-stale=0’,  
‘REQUEST\_URI’: ‘/redirect/8ddcc113-092e-46ce-845b-462b825ea792’,  
‘HTTP\_ACCEPT’:  
'text/html,application/xhtml+xml,application/xml;q=0.9,_/\*;q=0.8’,  
‘wsgi.version’: (1, 0), ‘x-wsgiorg.fdevent.timeout’: None,  
‘HTTP\_X\_FORWARDED\_FOR’: ‘10.load.bal.ip’, ‘wsgi.errors’: \<open file  
‘wsgi\_errors’, mode ‘w’ at 0x19955d0\>, ‘REMOTE\_PORT’: ‘51791’,  
‘HTTP\_ACCEPT\_LANGUAGE’: ‘en-US,en;q=0.8’, ‘wsgi.run\_once’: False,  
‘HTTP\_X\_FORWARDED\_PORT’: ‘80’, ‘CONTENT\_TYPE’: ‘’, ‘wsgi.file\_wrapper’:  
, ‘HTTP\_ACCEPT\_ENCODING’:  
‘gzip,deflate,sdch’}

----- Original Message -----  
From: jeff thomas [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Cc:  
Sent: Monday, June 18, 2012 4:26 PM  
Subject: nginx keeps passing the same http\_cookie to uwsgi

I have a small python app running via uwsgi with requests served by  
nginx.

I’m printing the environment variables… and it looks like after a  
couple of ok requests, nginx is sending the same HTTP\_COOKIE param for  
unrelated requests:

For example:  
{‘UWSGI\_CHDIR’: ‘/ebs/py’, ‘HTTP\_COOKIE’:  
‘ge\_t\_c=4fcee8450c3bee709800920c’, ‘UWSGI\_SCRIPT’: ‘server’,  
‘uwsgi.version’: ‘1.1.2’, ‘REQUEST\_METHOD’: ‘GET’, ‘PATH\_INFO’:  
‘/redirect/ebebaf3b-475a-4010-9a72-96eeff797f1e’, ‘SERVER\_PROTOCOL’:  
‘HTTP/1.1’, ‘QUERY\_STRING’: ‘’, ‘x-wsgiorg.fdevent.readable’: , ‘CONTENT\_LENGTH’: ‘’, ‘uwsgi.ready\_fd’:  
None, ‘HTTP\_USER\_AGENT’: ‘Mozilla/5.0 (compatible; MSIE 9.0; Windows NT  
6.1; WOW64; Trident/5.0)’, ‘HTTP\_CONNECTION’: ‘close’, ‘HTTP\_REFERER’:  
‘[http://www.facebook.com/](http://www.facebook.com/)’, ‘SERVER\_NAME’: ‘[pixel.domain.com](http://pixel.domain.com)’,  
‘REMOTE\_ADDR’: ‘10.load.bal.ip’, ‘wsgi.url\_scheme’: ‘http’,  
‘SERVER\_PORT’: ‘80’, ‘wsgi.multiprocess’: True, ‘uwsgi.node’:  
‘[py.domain.com](http://py.domain.com)’, ‘DOCUMENT\_ROOT’: ‘/etc/nginx/html’, ‘UWSGI\_PYHOME’:  
‘/ebs/py’, ‘uwsgi.core’: 127, ‘HTTP\_X\_FORWARDED\_PROTO’: ‘http’,  
‘x-wsgiorg.fdevent.writable’: ,  
‘wsgi.input’:  
\<newrelic.api.web\_transaction.WSGIInputWrapper object at 0x1809b90\>,  
‘HTTP\_HOST’: ‘[track.domain.com](http://track.domain.com)’, ‘wsgi.multithread’: False,  
‘REQUEST\_URI’: ‘/redirect/ebebaf3b-475a-4010-9a72-96eeff797f1e’,  
‘HTTP\_ACCEPT’: ‘text/html, application/xhtml+xml, _/_’, ‘wsgi.version’:  
(1, 0), ‘x-wsgiorg.fdevent.timeout’: None, ‘HTTP\_X\_FORWARDED\_FOR’:  
‘10.load.bal.ip’, ‘wsgi.errors’: \<open file ‘wsgi\_errors’, mode ‘w’ at  
0x1995390\>, ‘REMOTE\_PORT’: ‘36462’, ‘HTTP\_ACCEPT\_LANGUAGE’: ‘en-US’,  
‘wsgi.run\_once’: False, ‘HTTP\_X\_FORWARDED\_PORT’: ‘80’, ‘CONTENT\_TYPE’:  
‘’, ‘wsgi.file\_wrapper’: ,  
‘HTTP\_ACCEPT\_ENCODING’: ‘gzip, deflate’}

and

{‘UWSGI\_CHDIR’: ‘/ebs/py’,  
‘HTTP\_COOKIE’:‘ge\_t\_c=4fcee8450c3bee709800920c’, ‘UWSGI\_SCRIPT’:  
‘server’,‘uwsgi.version’: ‘1.1.2’,‘REQUEST\_METHOD’: ‘GET’,  
‘PATH\_INFO’:‘/redirect/2391e658-95ef-4300-80f5-83dbb1a0e526’,  
‘SERVER\_PROTOCOL’:‘HTTP/1.1’, ‘QUERY\_STRING’: ‘’,  
‘x-wsgiorg.fdevent.readable’:,  
‘CONTENT\_LENGTH’: ‘’,‘uwsgi.ready\_fd’: None, ‘HTTP\_USER\_AGENT’:  
‘Mozilla/5.0 (iPad; CPU OS5\_1\_1 like Mac OS X) AppleWebKit/534.46  
(KHTML, like Gecko)Version/5.1 Mobile/9B206 Safari/7534.48.3’,  
‘HTTP\_CONNECTION’:  
‘close’, ‘HTTP\_REFERER’: ‘[http://www.facebook.com/](http://www.facebook.com/)’,  
‘SERVER\_NAME’:‘[pixel.domain.com](http://pixel.domain.com)’, ‘REMOTE\_ADDR’: ‘10.load.balancer.ip’,  
‘wsgi.url\_scheme’: ‘http’, ‘SERVER\_PORT’: ‘80’,  
‘wsgi.multiprocess’:True, ‘uwsgi.node’: ‘[py.domain.com](http://py.domain.com)’,  
‘DOCUMENT\_ROOT’:  
‘/etc/nginx/html’, ‘UWSGI\_PYHOME’: ‘/ebs/py’, ‘uwsgi.core’:  
127,‘HTTP\_X\_FORWARDED\_PROTO’: ‘http’, ‘x-wsgiorg.fdevent.writable’:  
,  
‘wsgi.input’:\<newrelic.api.web\_transaction.WSGIInputWrapper object at  
0x18f3850\>,‘HTTP\_HOST’: ‘[fire.domain.com](http://fire.domain.com)’, ‘wsgi.multithread’:  
False,‘REQUEST\_URI’: ‘/redirect/2391e658-95ef-4300-80f5-83dbb1a0e526’,  
‘HTTP\_ACCEPT’:‘text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8’,‘wsgi.version’:  
(1, 0), ‘x-wsgiorg.fdevent.timeout’: None,  
‘HTTP\_X\_FORWARDED\_FOR’: ‘10.load.bal.ip’, ‘wsgi.errors’: \<open  
file’wsgi\_errors’, mode ‘w’ at 0x1796e40\>, ‘REMOTE\_PORT’: ‘39498’,  
‘HTTP\_ACCEPT\_LANGUAGE’: ‘en-us’, ‘wsgi.run\_once’:  
False,‘HTTP\_X\_FORWARDED\_PORT’: ‘80’, ‘CONTENT\_TYPE’:  
‘’,‘wsgi.file\_wrapper’: ,‘HTTP\_ACCEPT\_ENCODING’: ‘gzip, deflate’}

These are 2 distinct clients. I opened an incognito session, confirmed  
that no cookie was sent in the headers, and the uwsgi log shows that it  
received the same HTTP\_COOKIE.

How can I make sure that nginx only passes the proper information for  
the current request, without regard to other requests?

* * *

nginx mailing list  
removed\_email\_address@domain.invalid  
[http://mailman.nginx.org/mailman/listinfo/nginx](http://mailman.nginx.org/mailman/listinfo/nginx)

---

<div class="post-metadata">

**Author:** ![jeff\_thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ee59a6/32.png) [@jeff\_thomas](https://www.ruby-forum.com/u/jeff_thomas)\
**Post date:** [June 19, 2012, 3:41pm UTC](https://www.ruby-forum.com/t/nginx-keeps-passing-the-same-http-cookie-to-uwsgi/220735/3 "2012-06-19T15:41:33Z")

</div>

Hello!

On Mon, Jun 18, 2012 at 04:26:45PM -0700, jeff thomas wrote:

> I have a small python app running via uwsgi with requests served  
> by nginx.
> 
> I’m printing the environment variables… and it looks like  
> after a couple of ok requests, nginx is sending the same  
> HTTP\_COOKIE param for unrelated requests:

[…]

> These are 2 distinct clients. I opened an incognito session,  
> confirmed that no cookie was sent in the headers, and the uwsgi  
> log shows that it received the same HTTP\_COOKIE.
> 
> How can I make sure that nginx only passes the proper  
> information for the current request, without regard to other  
> requests?

Try tcpdump to see what actually happens on the wire between nginx  
and your uwsgi backend. Unless you see unrelated cookie there -  
the problem isn’t in nginx.

Maxim D.
