: 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
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?
More posts by @Reiling115
1 Comments
Sorted by latest first Latest Oldest Best
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.