Haproxy-Nginx http to https redirection issue.

I have redirected http to https via haproxy to nginx as backend server. But nginx displays empty page after redirection. Can somebody help me out?

tuckeranddale's picture

Update your server

First of all you should update your server so that you run the most current versions of NGINX and HAProxy.

 

sudo apt-get upgrade nginx

sudo apt-get upgrade haproxy

sudo apt get update nginx

sudo apt get update haproxy

After this check Nginx

sudo nano /etc/nginx/sites-available/example

and set listen to 443 instead of 80. Also you should check your firewall or CDN settings so that the correct port is open. Normally web traffic goes through port 80 and SSL traffic goes to port 443. So make sure that port 443 is open and that NGINX listens also on this port.

After that you can simply configure the http -> https redirection in the HAProxy configuration file. I guess you want to have a redirection for the entire website. That's why you should run a 301 permanent redirect. With a 301 redirection you instruct your browser to run always an http -> https redirection. As you configure the HAProxy directly, no other stack should be able to interrupt the redirection.

redirect scheme https code 301 if !{ ssl_fc }

Dont forget to restart Nginx and HaProxy

restart haproxy

restart nginx

Please let me know if that helped

 

Vote the answer: 
0
No votes yet