After I deployed my new shiny blog and postin the response to the first comment the server gave me a 500 (internal server) error.
Django mailed an errormessage to me (very nice):
invalid input syntax for type inet: "2a01" LINE 1: ...de', E'', E'test', E'2011-02-18 23:41:56.785693', E'2a01', t...
My setup is as follows:
- Django 1.3 (trunk atm)
- executed by gunicorn
- proxied by apache2
- postgresql 8.4 database
- client connected via IPv6.
The error occured in the comment application. I thought django would catch invalid values before executing the query. As I developed with postgresql 9, I suspected postgresql 8.4 could maybe not handle the ipv6 address? Just a wild guess. So I upgraded to postgresql 9 - but still the same problem.
Long story short: After rebuilding the deployment setup step-by-step on my development machine, it turned out, that gunicorn reported the wrong REMOTE_ADDR to django.
And why did it to that? Because the X-Forwarded-For header set by apache when proxying does not contain the port, just the pure IPv6 addresses (without the brackets embracing it to distinguish the colons in the address from the colon for the port). Gunicorn was not prepared to handle IPv6 adresses without brackets.
I filed a bug report and provided a possible patch, so I think the problem will be fixed in gunicorn soon.
