Forwarding Requests to Multiple Upstream Servers?

piespy piespy at gmail.com
Wed Jul 9 23:50:56 MSD 2008


On 7/9/08, Sven C. Koehler <schween at snafu.de> wrote:
>  I am wondering whether it's possible from within an nginx module to
>  forward a request to multiple upstream servers....

You can multiply one request to go to many servers using SSI.

Make the POST target location enable SSI, and be a document like this:

<!--# include virtual="/server1/upload" -->
<!--# include virtual="/server2/upload" -->
<!--# include virtual="/server3/upload" -->
<!--# include virtual="/server4/upload" -->
<!--# include virtual="/server5/upload" -->
<!--# include virtual="/server6/upload" -->

Then each /serverN location should have the appropriate proxy_pass
setting. You'll probably want to mark them all "internal". Only one of
the servers should probably actually produce output, unless it's just
something like "Upload to serverN: complete".

Note that these subrequests will be using the GET method (since
0.6.26), but by default still include the original request headers and
body. As long as your environment can deal with GETs having a request
body (PHP had some problems with it in my case), this should do what
you want, if you haven't yet decided on a different replication
method.





More information about the nginx mailing list