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 have a new version of our app and it needs to be tested before placed everywhere in production.

There is one main machine that currently receives all requests and forwards them to an Apache using proxy_pass. I want to add another server, and forward only some GET requests to it.

Can nginx be configured to do that?

share|improve this question
    
Can you be more specific about what requests need to go to what server? Is it a specific path that will have the GET requests in question, or? –  Shane Madden Oct 4 '11 at 0:54

2 Answers 2

up vote 0 down vote accepted

Yes, you need to setup a second upstream in your configuration and then use something to send specific requests there. Like:

upstream old_upstream {
    1.2.3.4:8080;
}
upstream new_upstream {
    5.6.7.8:8080;
}
set $upstream old_upstream;
if ( somecondition where you want to use the new server ) {
  set $upstream new_upstream;
}
location / {
  proxy_pass http://$upstream;
}
share|improve this answer

Or you can simply go without upstreams and use the short version.

location / {
  if (somecondition for new server ) {
    proxy_pass http://5.6.7.8:8080;
    break;
  }

  proxy_pass http://1.2.3.4:8080;
}

please +1 if it helped :) thanks

share|improve this answer

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.