HAProxy将http重定向到https(ssl) [英] HAProxy redirecting http to https (ssl)

查看:3418
本文介绍了HAProxy将http重定向到https(ssl)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HAProxy进行负载平衡,只希望我的网站支持https。因此,我想将端口80上的所有请求重定向到端口443.

I'm using HAProxy for load balancing and only want my site to support https. Thus, I'd like to redirect all requests on port 80 to port 443.

我该怎么做?

编辑:我们想在https上重定向到相同的网址,保留查询参数。因此, http://foo.com/bar 将重定向到 https://foo.com/bar

We'd like to redirect to the same url on https, preserving query params. Thus, http://foo.com/bar would redirect to https://foo.com/bar

推荐答案

我发现这是最大的帮助

使用HAProxy 1.5-dev13或更新版本,只需将以下行添加到前端配置中:

Use HAProxy 1.5-dev13 or newer, and simply add the following line to the frontend config:

redirect scheme https code 301 if !{ ssl_fc }

这篇关于HAProxy将http重定向到https(ssl)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆