-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document why REMOTE_ADD may not be the user's IP address #1037
Document why REMOTE_ADD may not be the user's IP address #1037
Conversation
2a8e67b
to
8e6b5dc
Compare
Gunicorn v19 removed functionality which updated `REMOTE_ADDR` to the value of the `X-Forwared-For` header if received from a trusted upstream client. This was a violation of RFC 3875 CGI Version 1.1, and was hence removed. Close: benoitc#1035 PR-URL: benoitc#1037 Related: benoitc#633 Signed-off-by: Hans Kristian Flaatten <hans.kristian.flaatten@turistforeningen.no>
REMOTE_ADD
may not be the user's IP
LGTM |
Maybe also add that |
@Starefossen good idea :) |
8e6b5dc
to
e0aad07
Compare
Gunicorn v19 removed functionality which updated `REMOTE_ADDR` to the value of the `X-Forwared-For` header if received from a trusted upstream client. This was a violation of RFC 3875 CGI Version 1.1, and was hence removed. Close: benoitc#1035 PR-URL: benoitc#1037 Related: benoitc#633 Signed-off-by: Hans Kristian Flaatten <hans.kristian.flaatten@turistforeningen.no>
Ok, I have now amended a paragraph to my original commit. |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
... | ||
|
||
It is also worth noticing that the ``REMOTE_ADDR`` will be completely empty if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"worth noting" would be the typical phrase, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, and fixed!
e0aad07
to
7b6f8a2
Compare
Gunicorn v19 removed functionality which updated `REMOTE_ADDR` to the value of the `X-Forwared-For` header if received from a trusted upstream client. This was a violation of RFC 3875 CGI Version 1.1, and was hence removed. Close: benoitc#1035 PR-URL: benoitc#1037 Related: benoitc#633 Signed-off-by: Hans Kristian Flaatten <hans.kristian.flaatten@turistforeningen.no>
... | ||
|
||
It is also worth noting that the ``REMOTE_ADDR`` will be completely empty if you | ||
bind Gunicorn to a unix socket and not a tcp host:port touple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one last typo :) s/touple/tuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what you get for not running spell check before pushing 😝 Fixed now.
I love documentation PRs!!! :) :) |
@tilgovi +1 :) |
@tilgovi :) |
Gunicorn v19 removed functionality which updated `REMOTE_ADDR` to the value of the `X-Forwared-For` header if received from a trusted upstream client. This was a violation of RFC 3875 CGI Version 1.1, and was hence removed. Close: benoitc#1035 PR-URL: benoitc#1037 Related: benoitc#633 Signed-off-by: Hans Kristian Flaatten <hans.kristian.flaatten@turistforeningen.no>
7b6f8a2
to
85d857d
Compare
I'm just happy to be of any help. Thank you for making Gunicorn ❤️ |
Document why REMOTE_ADD may not be the user's IP address
Thanks! |
The doc change introduced in #1037 is initially helpful but then internally inconsistent. It correctly points out that X-Forwarded-For is no longer used in setting REMOTE_ADDR (c487368), but then confusingly indicates a solution using the X-Forwarded-For header. The deployment doc provides a full configuration example which includes proxy headers as set by nginx. What is missing, before this patch, is a clear suggestion on how to make use of the header in Gunicorn's access log. Accordingly, remove the confusing suggestion and replace it with a drop-in replacement for Gunicorn's default access log format.
This PR updates the Gunicorn deploy documentation on why
REMOTE_ADDR
may not always be the IP address of the user.Close: #1035
Related: #633
Signed-off-by: Hans Kristian Flaatten hans.kristian.flaatten@turistforeningen.no