以下の内容はhttps://iww.hateblo.jp/entry/20250613/proxy_set_headerより取得しました。


proxy_set_header でヘッダーを設定する

proxy_set_header でヘッダーを設定するとき、設定が複数個所にあると 設定されなくなることがある

server {
    proxy_set_header X-Forwarded-Proto $scheme; # ★A

    location / {
        # ★Aは有効
    }

    location /hoge {
        proxy_set_header Host $host; # ★B
        # ★Aは無効!
        # ★Bは有効
    }
}

このようにディレクティブの内と外に設定があると、外側でおこなわれた設定は無かったことになって、内側の設定のみになる。

These directives are inherited from the previous configuration level if and only if there are no proxy_set_header directives defined on the current level.

これらは、現在のレベルで proxy_set_header が定義されていない場合にのみ、前の設定レベルから継承されます

Module ngx_http_proxy_module

つまり proxy_set_header が定義されてなければ カッコの外で定義したものが引き継がれるけど
カッコの中でproxy_set_header が定義されたら、それまでの定義はすべて捨てられる。
カッコの中に入らなければ(マッチしなければ)セーフ、捨てられない。

偶然が重なってすぐ気づけたけど、普段なら死んでそうな罠だった




以上の内容はhttps://iww.hateblo.jp/entry/20250613/proxy_set_headerより取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14