If I have only 2 servers, can I make each as a backend and also front end?

Server 1: master load balancer / backend server1 Server 2: slave load balancer / backend server2

is it possible?


Yes, it's possible and pretty easy to get it done. Check the nginx wiki. You can bind the "webserver" part on a different port than 80 and the load balancer (or proxy if is the case) on port 80. Use something like this:

loadb vhost

upstream app {
server {
   listen 80;
   // all the usual bla bla
   location / {
       proxy_pass http://app;

use the webserver vhost like a default one, just with "listen 81" instead of "listen 80". This is untested, I just copied few of the lines from my config that is running only as a proxy and the backend servers are on different machines... but it should work without any problem.

If you also want to load balance between those 2 proxies, try ultramonkey in front of the nginx and all your requests will distributed equal to both servers (or you can do it with nginx)

  • how should I config master/slave load balancer? or they are just the parallel balancers? – Ben Jul 22 '10 at 3:47
  • so you want to have a high availability system? if one server (proxy) goes down, the other one to take all the requests? For this, you should use ultramonkey (ha.d and ldirector). You can check on their website because they have sample configurations for different scenarions (you need High Availability and Load Balancing). Then you will have on both servers: tcp/80 ultramonkey, tcp/81 webservers. You won't need nginx to make the load balancing, just to serve the files from it. – MihaiM Jul 22 '10 at 7:39
  • Tks MihaiM, the problem is the project seems no update anymore, the latest version is done at 2005? isn't it? – Ben Jul 22 '10 at 12:03
  • i'm using it in a for a large website and is working like a charm. You can try HAProxy which does almost the same thing and uses the same base like ultramonkey (ha.d). as far as i know, that one is updated (at the moment i cannot access their website) – MihaiM Jul 22 '10 at 16:20
  • Seems HAProxy is good choice. Thank you very much. – Ben Jul 22 '10 at 23:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.