背景
nginx -> nginx -> railsのように多段のリバースプロキシーに対応した、nginxのX-Forwarded設定。
nginxのX-Forwarded設定 (location抜粋)
location @proxy {
proxy_set_header Host $http_host;
# 伝播させていく
set $ssl off;
if ($scheme = https) {
set $ssl on;
}
if ($http_x_forwarded_for) {
set $ssl $http_x_forwarded_for;
}
set $proto $scheme;
if ($http_x_forwarded_proto) {
set $proto $http_x_forwarded_proto;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-SSL $ssl;
proxy_set_header X-Forwarded-Proto $proto;
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
internal;
}