Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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 192.168.1.2:81;
   server 192.168.1.3:81;
}
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)

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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