Mobile app version of vmapp.org
Login or Join
Reiling115

: Setting up Nginx Load Balancing I'm setting up an Nginx web server and and want to perform load balancing using the round robin method. This is what I have found thus far: upstream backend

@Reiling115

Posted in: #Nginx #WebHosting

I'm setting up an Nginx web server and and want to perform load balancing using the round robin method. This is what I have found thus far:

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


According to the page they says i need to add the above lines to my nginx.conf file and upload it to server to load balance. I do not understand what it means by server backend3.example.com;. How do I setup a backend instance?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Reiling115

1 Comments

Sorted by latest first Latest Oldest Best

 

@Miguel251

Those are the backend servers that will handle the incoming request.

So your domain's DNS should point to this nginx server, which will then use your upstream configuration to pass the request to one of the specified servers.

Your config should look something like this (inside http {} block)...

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

server {
location / {
proxy_pass backend; }
}


Some notes...


You can use the load balancer as another 'backend' if you want to.
If you need https, then simply change proxy_pass backend; to proxy_pass backend; but make sure your backend servers are prepared to handle https.
If your backend service uses sessions (such as PHP sessions), then you will need to setup some kind of session persistence, but that is unrelated.


You can find much more information for advanced configuration in the docs of nginx.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme