我在traefik入口后面运行Gunicorn。traefik将HTTP重定向到HTTPS,但由于某种原因,gunicorn回复了指向HTTP的301。我已经尝试了几乎所有我知道的选项,但没有找到任何解决方案。我想它可能和https://stackoverflow.com/a/41488430/3719845之类的东西有关。
以下是我在入口中使用的注释:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/frontend-entry-points: http,https
traefik.ingress.kubernetes.io/protocol: http
ingress.kubernetes.io/ssl-redirect: 'true'
traefik.frontend.rule.type: PathPrefix
ingress.kubernetes.io/custom-request-headers: 'x-forwarded-proto:https||x-forwarded-ssl:on||x-forwarded-protocol:ssl'我不确定traefik是否自动设置了x-forwarded标头,所以我对它们进行了硬编码。
在gunicorn方面,我使用:
command:
- '/usr/local/bin/gunicorn'
args:
- '-b'
- '0.0.0.0:8080'
- '--log-level'
- 'debug'
- '--access-logfile'
- '-'
- '--error-logfile'
- '-'
- '--forwarded-allow-ips'
- '0.0.0.0'
- '--proxy-allow-from'
- '0.0.0.0'
- '--proxy-protocol'
- 'myapp'这里也是一样,我一直在尝试选择,但似乎什么都没有改变。
发布于 2019-04-19 00:12:23
在你的头上试试这个:
ingress.kubernetes.io/ssl-proxy-headers: "X-Forwarded-Proto: https"
ingress.kubernetes.io/ssl-redirect: "true"(这是用于aws elb的配置。我不知道导致它的具体配置)
在那里,您可能会遇到一个不尊重X-Forwarded-Proto报头的gunicorn问题,并希望检查他们的文档。
https://stackoverflow.com/questions/55749349
复制相似问题