Search code examples
nginxload-balancinghaproxy

Where should SSL be installed


I have got a setup like this

Load balancer

Machine 1 - haproxy load balancer
Machine 2 - haproxy load balancer

Web servers

Machine 1 - nginx with app
Machine 2 - nginx with app

Now where should I set up SSL certificate. On loadbalancers or web servers or on both?

What is the correct way of doing it?


Solution

  • The "correct way" to do this depends on your setup. If your load balancers are on the same machines as your webservers, it doesn't matter which you choose to put the cert on. If they are on different servers, encryption depends on how important security is for these particular web apps. If you put the certs on the load balancers you will have unencrypted traffic visible to anyone in your network (as it goes from load balancer to server). If you put certs on your nginx server you will have encryption all the way through to the local server, but you will have to change your haproxy a little to have it route encrypted traffic properly. You also will not be able to route off the url path. You can also put certs on both to be able to route off the url path, but that is a little more to manage (two certs vs one). Overall it's probably best to put the cert on nginx server, assuming your don't need to do any routing in the load balancer off of the url. Also definitely do your own research.