【发布时间】:2017-06-21 07:40:36
【问题描述】:
我的应用程序不需要响应 http 请求,除了将它们重定向到 https,但我无法为此配置它。我有 Django,在 Guincorn 后面,在 Google Cloud 4 级负载均衡器后面(通过 kubernetes 设置)。我没有使用 nginx,因为静态文件是通过谷歌云存储桶提供的,所以它似乎增加了不必要的复杂性(这是错误的原因吗?)
当我为 https 配置 guincorn 时,它不响应 http 请求(好的)。我的第一个想法是通过负载均衡器转发端口 80 和 443,然后让 django/guincorn 负责重定向,但我无法让 guincorn 同时为 http 和 https 提供服务,即使我尝试公开两个端口:
gunicorn --threads 2 -b :8000 --keyfile=key.txt --certfile=cert.txt myapp.wsgi
负载均衡器配置为:
apiVersion: v1
kind: Service
metadata:
name: xxx
labels:
name: xxx
spec:
ports:
- port: 443
name: https
targetPort: 8000
selector:
name: app
type: LoadBalancer
loadBalancerIP: xx.xx.xx.xx
是否可以更改此设置,以便 gunicorn 也响应 https 请求? (Django 配置设置为不重定向 http 请求)。
还是我完全错了?我应该尝试在负载均衡器本身上执行重定向吗?
【问题讨论】:
标签: django redirect kubernetes google-cloud-platform gunicorn