NginX : Route user request to backend

Posted by xperator on Server Fault See other posts from Server Fault or by xperator
Published on 2012-11-08T21:25:33Z Indexed on 2012/11/09 11:06 UTC
Read the original article Hit count: 276

Filed under:
|

The goal is to have NginX webserver act as a very basic & simple load balancer/fail-over. But instead of fetching static files from backend and serving it to user, I just want to route/redirect user request to one of the back end servers.

upstream backend  {
  server server1.example.com:80;
  server server2.example.com:80;
  server server3.example.com:80;
}

    location / {
proxy_pass  http://backend;
}

Instead of :

User request (example.com/test.file) > NginX LB > Backend > NginX LB > User

I want to have :

User request (example.com/test.file) > NginX LB > Backend > User

Is this even possible with NginX ? If not then How can I achieve this goal.

UPDATE 1: Is there a way to use rewrite directive with backend upstream ?

UPDATE 2: It's not really necessary to use NginX. I just want to have a direct reply from backend to user.

© Server Fault or respective owner

Related posts about nginx

Related posts about load-balancing