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.

I want to map a particular domain in nginx, and then have nginx round-robin to a list of servers that will response to http requests.

So I have nginx for www.domain1.com

Its a python application, and I have 10 instances of paste running on different ports that I want nginx to forward/proxy requests to using round-robin.

can it do this, if yes, how?

share|improve this question
add comment

2 Answers

You can specify ports for each backend server in an upstream block in nginx:

upstream mybackend  {
    server localhost:8080;
    server localhost:8081;
    server localhost:8082;
    server localhost:8083;
    server localhost:8084;
    server localhost:8085;
    server localhost:8086;
    server localhost:8087;
    server localhost:8088;
    server localhost:8089;
}

server {
  location / {
    proxy_pass  http://mybackend;
  }
}
share|improve this answer
add comment

Really, you'd be better off using something like haproxy for this, but nginx can reverse proxy to multiple servers at the backend.

Take a look at the upstream module for nginx http://wiki.nginx.org/NginxHttpUpstreamModule

Set upstream servers to the same weight for distributed round-robin balancing. e.g.

upstream backend { 
     server ww1.domain.com weight=10;
     server ww2.domain.com weight=10;
}

By default the weight is 1, so you technically don't need a weight of 10, but setting a higher default weight allows you to introduce a server with a lower weight easily.

share|improve this answer
    
this server is already running nginx, can I run both w/o them conflicting? I need haproxy for a different domain, nginx is hosting 2 other domains for me. –  Blankman Sep 8 '10 at 18:01
add comment

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.