1

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.

Vladimir
  • 145
  • 10

1 Answers1

0

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.

Danack
  • 1,216
  • 1
  • 16
  • 27
  • 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