nginx: Set X-Forwarded-For in common proxy configuration.

Previously we sometimes set it to $proxy_add_x_forwarded_for and other
times to $remote_addr, but according to

http://wiki.nginx.org/HttpProxyModule#.24proxy_add_x_forwarded_for

$proxy_add_x_forwarded_for handles this for us -- it will be
$remote_addr if there was no X-Forwarded-For header anyway.

(imported from commit 67dc52250e3e7751b1bf375d1a71d0272475435c)
This commit is contained in:
Tim Abbott 2013-12-03 17:25:07 -05:00
parent afe167ea58
commit afaff0c2cf
5 changed files with 1 additions and 9 deletions

View File

@ -19,7 +19,6 @@ location ~ /json/get_events|/json/events|/api/v1/events {
include /etc/nginx/zulip-include/proxy_longpolling; include /etc/nginx/zulip-include/proxy_longpolling;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} }
# Send sockjs requests to Tornado # Send sockjs requests to Tornado

View File

@ -4,4 +4,3 @@ include /etc/nginx/zulip-include/proxy_longpolling;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade; proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@ -1,4 +1,5 @@
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream off; proxy_next_upstream off;
proxy_redirect off; proxy_redirect off;

View File

@ -31,7 +31,6 @@ server {
location ~ /json/get_events|/json/events|/api/v1/events { location ~ /json/get_events|/json/events|/api/v1/events {
proxy_pass https://staging/; proxy_pass https://staging/;
include /etc/nginx/zulip-include/proxy_longpolling; include /etc/nginx/zulip-include/proxy_longpolling;
proxy_set_header X-Forwarded-For $remote_addr;
} }
} }
@ -56,7 +55,6 @@ server {
location ~ /json/get_events|/json/events|/api/v1/events { location ~ /json/get_events|/json/events|/api/v1/events {
proxy_pass https://prod/; proxy_pass https://prod/;
include /etc/nginx/zulip-include/proxy_longpolling; include /etc/nginx/zulip-include/proxy_longpolling;
proxy_set_header X-Forwarded-For $remote_addr;
} }
} }
@ -80,7 +78,6 @@ server {
location ~ /json/get_events|/json/events|/api/v1/events { location ~ /json/get_events|/json/events|/api/v1/events {
proxy_pass https://prod/; proxy_pass https://prod/;
include /etc/nginx/zulip-include/proxy_longpolling; include /etc/nginx/zulip-include/proxy_longpolling;
proxy_set_header X-Forwarded-For $remote_addr;
} }
} }
@ -105,7 +102,6 @@ server {
location ~ /json/get_events|/json/events|/api/v1/events { location ~ /json/get_events|/json/events|/api/v1/events {
proxy_pass https://prod/; proxy_pass https://prod/;
include /etc/nginx/zulip-include/proxy_longpolling; include /etc/nginx/zulip-include/proxy_longpolling;
proxy_set_header X-Forwarded-For $remote_addr;
} }
} }
@ -129,7 +125,6 @@ server {
location ~ /json/get_events|/json/events|/api/v1/events { location ~ /json/get_events|/json/events|/api/v1/events {
proxy_pass https://prod/; proxy_pass https://prod/;
include /etc/nginx/zulip-include/proxy_longpolling; include /etc/nginx/zulip-include/proxy_longpolling;
proxy_set_header X-Forwarded-For $remote_addr;
} }
} }
@ -154,7 +149,6 @@ server {
location ~ /json/get_events|/json/events|/api/v1/events { location ~ /json/get_events|/json/events|/api/v1/events {
proxy_pass https://prod/; proxy_pass https://prod/;
include /etc/nginx/zulip-include/proxy_longpolling; include /etc/nginx/zulip-include/proxy_longpolling;
proxy_set_header X-Forwarded-For $remote_addr;
} }
} }

View File

@ -1,2 +1 @@
include /etc/nginx/zulip-include/proxy; include /etc/nginx/zulip-include/proxy;
proxy_set_header X-Forwarded-For $remote_addr;