Dockerホストのリバースリバースプロキシとしてtraefikを使用しています。さらに、外部サーバーへの静的プロキシを設定したいと思います。これは私の現在の構成です:
defaultEntryPoints = ["http", "https"]
debug = false
logLevel = "ERROR"
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
compress = true
[entryPoints.https.tls]
[api]
[docker]
domain = "myhost.com"
watch = true
exposedByDefault = false
[file]
[backends]
[backends.otherhost]
[backends.otherhost.servers]
[backends.otherhost.servers.server0]
url = "http://otherhost.com"
[frontends]
[frontends.otherhost]
entryPoints = ["http", "https"]
backend = "otherhost"
[frontends.otherhost.routes]
[frontends.otherhost.routes.route0]
rule = "Host:subdomain.myhost.com"
[frontends.otherhost.headers.customRequestHeaders]
X-Forwarded-For = "foo"
X-Real-Ip = "foo"
ヘッダーを空の文字列に設定しても何も起こりませんでした。これらの設定でX-Real-Ip
はfoo
、X-Forwarded-For
ですがになりfoo, <my real IP>
ます。Docker環境内にクライアントIPを保持したまま、traefikがクライアントIPを外部バックエンドにリークするのを防ぐことはできますか?
ミドルウェアを使用してX-Forwarded-For
ヘッダーをオーバーライドするのはどうですか。ドキュメントはここにあります。
[http.middlewares]
[http.middlewares.testHeader.headers]
[http.middlewares.testHeader.headers.customRequestHeaders]
X-Forwarded-For = "foo"
[http.middlewares.testHeader.headers.customResponseHeaders]
X-Forwarded-For = "foo"
次に、次のように、特定のミドルウェアをルーターに適用できます。
[http.routers]
[http.routers.router1]
service = "myService"
middlewares = ["testHeader"]
rule = "Host(`example.com`)"
[http.middlewares]
[http.middlewares.testHeader.headers]
[http.middlewares.testHeader.headers.customRequestHeaders]
X-Forwarded-For = "foo"
[http.middlewares.testHeader.headers.customResponseHeaders]
X-Forwarded-For = "foo"
[http.services]
[http.services.service1]
[http.services.service1.loadBalancer]
[[http.services.service1.loadBalancer.servers]]
url = "http://127.0.0.1:80"
参照:
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加