Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Gunicorn w/ Django on nginx + unix socket: REMOTE Adress is "b''" (a string containing the three characters b'') #1755
I just had a huge "wtf moment" when I was setting up a Django Middleware to parse the
Now, as already discussed in issue #797 gunicorn does not provide the
So I thought I'll just make this little thing in a Django Middleware:
if request.META['REMOTE_ADDR'] == "": # empty string request.META['REMOTE_ADDR'] = request.META['HTTP_X_FORWARDED_FOR'].split(",").strip()
Oh well... It seems that I was wrong.
Would you like to know what
I believe this is not the intended behaviour, though I'm not involved enough with the whole gunicorn/nginx unix socket setup to point out where the error might be.
Here are some Details of the software that is being used:
Gunicorn is started via systemd with the following command:
Nginx is configured as follows:
I've created an example repo:
Feel free to check it out, it should be easy to reproduce.
It seems like this issue is related to the python version, rather than gunicorn.
I'm just making an educated guess here, but I believe that python issue 30205 is the cause (patch has been included with Python 3.5.4 and Python 3.6.2).
I'm not 100% sure if you can fix this in gunicorn. However, the problem is appearing on a debian 9.4, so this issue is probably affecting quite a bunch of users.