noobprog
noobprog

Reputation: 337

How to configure nginx with multiple server

Im new with nginx as well as load balancing, rediction etc. I have 2 tornado web servers running on port 8000 and 8001 and 2 geoserver instance running on tomcat7 servelet with ports 8080 and 8081. Can someone teach me in such a way that nginx could listen to port 80 and base_url/tornado will be redirected to the tornado servers and base_url/geoserver will be redirected to the tomcat7 servelet.

Thanks to those who would help me. :)

Upvotes: 1

Views: 1995

Answers (1)

Erez Rabih
Erez Rabih

Reputation: 15788

This should be a good lead for you towards the solution:

upstream tornado {
  server 127.0.0.1:8000;
  server 127.0.0.1:8001;
}

upstream geoserver{
  server 127.0.0.1:8080;
  server 127.0.0.1:8081;
}
server {
  server_name _;
  listen 80;
  location = /tornado {
    proxy_pass http://tornado;
  }

  location = /geoserver {
    proxy_pass http://geoserver;
  }
}

Hope it helps!

Upvotes: 3

Related Questions