Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have

  • one service called legacy-service
  • another service called dev-service
  • bunch of HTTP requests coming to the legacy-service

Is there any way to proxy HTTP requests to both legacy-service and new-service without writing custom utility? So I can test my dev-service on real traffic, but without turning off legacy-service.

share|improve this question

Yes, you can use the upstream module to have nginx load-balance requests to different backends.

In the global block:

upstream backend {
    server unix:/dev/shm/.php-fpm/socket;
    server unix:/dev/shm/.php-fpm/socket2;

Or use server IP addresses or domain names, if you want the requests to go to other machines, rather than different PHP instances.

And then in the server block:

location ~ \.php$
    include fastcgi_params;
    fastcgi_pass backend;
    fastcgi_index index.php;
    fastcgi_send_timeout 15;
    fastcgi_read_timeout 15;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

The backends can also be IP/domain names, to allow you to load-balance to other machines.

share|improve this answer
AFAIK your config can be used for load balancing, i.e. first request will go to the server-1, second request will go to the server-2. But I want that each server handles each request. – Vladimir Mar 20 '13 at 13:02
Sorry I'm not sure what you mean. "But I want that each server handles each request" you mean each request goes to both servers? If that's what you mean, what response to you expect to be sent to the caller of the service? – Danack Mar 20 '13 at 13:17

Your Answer


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.