我无法让HAProxy永久地将所有请求重定向到HTTP到HTTPS .
我已将标准Opsworks HAProxy配置Chef配方安装为自定义配方,并尝试将其修改为重定向请求 . 我没有成功 .
有人可以帮我修改吗?
有4个域/子域,它们都应该被强制为HTTPS .
-
app.domain.com
-
api.domain.com
-
app.domain2.com
-
api.domain2.com
我尝试过以下方法:
-
将前端http-in default_backend更改为HTTPS后端 . 它给了我几个错误
ignored for backend 'php_app_servers_ssl Unable to use proxy 'php_app_servers_ssl' with wrong mode, required: http, has: tcp.' as it requires HTTP mode
. 此错误发生在部署日志中 . -
将前端https-in模式更改为http(以解决上一个错误) . 部署工作但在HTTP上提供了400 Bad请求,在HTTPS上提供了
Failed to load resource: net::ERR_CONNECTION_CLOSED
. -
在前端http-in中添加了
redirect scheme https if !{ ssl_fc }
,由于HAProxy的版本,可能会出现此错误'redirect' expects 'code', 'prefix', 'location', 'set-cookie', 'clear-cookie', 'drop-query' or 'append-slash' (was 'scheme').
. 'redirect'需要1.5或更高版本(我相信) . -
添加了
redirect prefix https://app.domain.com if is_http { hdr(host) -i app.domain.com }
,这在部署日志中给了我这个错误:'redirect': error detected while parsing redirect condition.
-
更正了上面的重定向(地址错误)并且部署成功,但浏览器现在再次在HTTP上返回400 Bad请求,在HTTPS上返回
Failed to load resource: net::ERR_CONNECTION_CLOSED
.
我对尝试什么没有任何想法 . 有人可以帮我对配置文件进行必要的更正吗?
谢谢 .