Saturday, September 6, 2014

Nginx as a load balancer

How to configure Nginx as a Load balancer

sudo apt-get install nginx

nano /etc/nginx/sites-available/default

First we need to include the upstream module which looks like this:

upstream backend  {
  server backend1.example.com;
  server backend2.example.com;
  server backend3.example.com;
}

We should then reference the module further on in the configuration:

 server {
  location / {
    proxy_pass  http://backend;
  }
}

sudo service nginx restart

No comments:

Post a Comment