我们使用LVS进行负载平衡,并希望为http://example.com重定向到https://example.com
LVS可以在没有问题的情况下启用https,但是没有将http真正的服务器添加到池中(权重为0)。
LVS不遵循301重定向吗?如果没有,如何配置ldirectord将所有HTTP流量发送到HTTPS?
下面是nginx配置:
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443;
ssl on;
ssl_certificate server.crt;
ssl_certificate_key server.key;
server_name example.com;
# more here
}ldirectord.cf看起来是这样的:
virtual=VIP:80
fallback=127.0.0.1:80
real=10.0.0.7:80 masq 5
real=10.0.0.8:80 masq 5
service=http
request="lvs.htm"
receive="lvs"
virtualhost=example.com
scheduler=wlc
protocol=tcp
checktype=negotiate
virtual=VIP:443
fallback=127.0.0.1:443
real=10.0.0.7:443 masq 5
real=10.0.0.8:443 masq 5
service=https
request="lvs.htm"
receive="lvs"
virtualhost=example.com
scheduler=wlc
protocol=tcp
checktype=negotiate我还尝试将VIP设置为端口80,将RIP端口设置为443,这导致服务器被添加到池中,但nginx随后返回一个400“普通HTTP请求被发送到HTTPS端口”错误。
发布于 2013-07-31 03:12:35
我让这件事变得更难了。
我修改了我的nginx.conf如下:
server {
listen 80;
server_name example.com;
root /var/www;
location = /lvs.htm {
#do nothing
}
location / {
return 301 https://example.com$request_uri;
}
}lvs.htm驻留在/var/www中,因此匹配位置,搜索停止,并向lvs.htm提供200个响应代码。LVS将服务器添加到池中,当它被击中时,nginx将正确地用301重定向到https。
https://serverfault.com/questions/525624
复制相似问题