Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k8s部署,如果禁用http协议,使用https无法访问首页 #2823

Open
liuliaozhong opened this issue Dec 4, 2024 · 0 comments
Open
Assignees
Labels
backlog bug Something isn't working

Comments

@liuliaozhong
Copy link
Contributor

What happened:
在k8s环境中,如果禁用http协议,使用https访问首页,会重定到http访问失败,如下
image

分析:
image
如果 NGINX 位于Kubernetes的Pod内并且背后有代理(如Ingress控制器、负载均衡器等),它从客户端接收到的请求已经可能经过了一些代理层。这时 $scheme 变量只能反映NGINX和负载均衡器之间的协议,而不能反映客户端到负载均衡器之间的协议。但如果外部请求是通过HTTPS发起的,NGINX并没有直接获得客户端的协议信息,因此$scheme只是反映代理层的协议状态。
修复建议:
可以使用$http_x_forwarded_proto替带$Scheme, http_x_forwarded_proto变量更能准确地反映客户端的原始请求协议

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants