在后端重定向的情况下,Traefik不会修改位置标头

问题描述 投票:0回答:1

我正在使用Traefik用Letsencrypt实现反向代理和Apache docker容器。一切都运作良好,除非后端为某些资源返回301/302重定向。例如:

curl https://example.com/js/conf.js
> GET /js/conf.js HTTP/2
> Host: example.com
> User-Agent: curl/7.64.0
> Accept: */*
>

< HTTP/2 302
< cache-control: no-store, no-cache, must-revalidate
< content-type: text/html; charset=iso-8859-1
< date: Wed, 27 Mar 2019 16:50:05 GMT
< expires: Thu, 01 Jan 1970 00:00:00 GMT
< location: http://example.com/it/js/conf.js
< server: Apache/2.4.34 (Unix) OpenSSL/1.0.2l
< content-length: 224
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://example.com/it/js/conf.js">here</a>.</p>
</body></html>

我希望traefik将位置标题设置为https://example.com/it/js/conf.js

这是我正在使用的配置:

debug = true

logLevel = "info"
defaultEntryPoints = ["https","http"]

#[accessLog]

[api]
  dashboard = true

[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.https]
  address = ":443"
  [entryPoints.https.tls]

[retry]

[docker]
endpoint = "unix:///var/run/docker.sock"
watch = true
exposedByDefault = false

[acme]
email = "[email protected]"
storage = "/etc/traefik/acme/acme.json"
entryPoint = "https"
onHostRule = true

[acme.httpChallenge]
entryPoint = "http"

我正在使用以下标签运行容器:

--label traefik.enable=true --label traefik.website.frontend.rule=Host:example.com --label traefik.frontend.redirect.entryPoint=https
apache https traefik
1个回答
1
投票

我和traefik和gunicorn here有一些类似的问题。在我的情况下,我必须通过X-FORWARDED_PROTO标头让网络服务器知道初始连接是通过HTTPS完成的。这可能就是您的Apache重定向到HTTP的原因。

© www.soinside.com 2019 - 2024. All rights reserved.