1

We're using LVS for load balancing and want to do a 301 redirect for http://example.com to https://example.com

LVS is enabling https without issue, but the http real servers are not being added to the pool (weight of 0).

Does LVS not follow 301 redirects? If not, how do I configure ldirectord to send all HTTP traffic to HTTPS?

Here is the nginx config:

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 } 

And ldirectord.cf looks like this:

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 

I also tried setting my VIP to port 80 and my RIP ports to 443 which resulted in the servers being added to the pool, but nginx then returns a 400 "The plain HTTP request was sent to HTTPS port" error.

1 Answer 1

1

I was making this harder than it needed to be.

I modified my nginx.conf as so:

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 resides in /var/www so the location is matched, searching stops and lvs.htm is served with a 200 response code. LVS adds the server to the pool and when it is hit, nginx correctly redirects to https with a 301.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.