frpとX-Forwarded-Protoヘッダー
frpとはローカルネットワーク内のサービスをNATやファイアウォールを越えて外部に公開するための、高速なリバースプロキシツールである。
私は、
nginx[443] (SSL終端) -> proxy_pass[http] -> frps[http] -> ...tunnel... -> frpc[http] -> local service[http]
のようなhttp proxy構成を試みた。その時、frpはX-Forwarded-Proto
ヘッダーを除去する挙動があり、これは仕様である。そのため、frpc側で、
requestHeaders.set.x-forwarded-proto = "https"
のように、あとからhttpsだよというヘッダーを付与せねばならない。このことは x-forwarded-proto gets stripped away in http proxies fatedier/frp #4168 からわかる。
iniでは設定が効かない
しかし、私の環境ではこの設定を追記しても直らなかった(frps,frpc共にバージョンは0.62.1)。適当なヘッダーを付与してtcpdump
で確認したところ、一切ヘッダーが追加されないことが判明した。
frpcのログを見ていたところ、
WARNING: ini format is deprecated and the support will be removed in the future, please use yaml/json/toml format instead!
の一文が目に入ったため、iniで書いていた設定ファイルをtomlに書き直したところ、正常に動作した。
iniはやめよう
https://github.com/fatedier/frp?tab=readme-ov-file#configuration-files
Since v0.52.0, we support TOML, YAML, and JSON for configuration. Please note that INI is deprecated and will be removed in future releases. New features will only be available in TOML, YAML, or JSON. Users wanting these new features should switch their configuration format accordingly.
release noteを見る限り、このX-Forwarded-Proto
を付与する機能はv0.58.0で追加されたものであるため、iniでは設定できず、toml, yaml, jsonじゃないと効かないパラメータである。