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'm trying to replicate the traffic that one specific nginx server receives to two servers. The goal is not to load-balance, but to replay the same input on all nginx servers.

An example: Nginx receives a HTTP POST. I want to send this same POST to other servers.

** UPDATE **

The situation is easy and non-complex. I just need to resend the POST data (or GET or any request data) to another server IP (it also running a nginx instance). Just it.


share|improve this question
Can you expand on your architecture? What are the other two servers? Is there a shared DB, shared filesystem, etc.? Does the POST write to the DB, to the filesystem, what? Actually, what are you trying to accomplish that can't be done with clustered filesystems and database instances? – cjc Aug 1 '12 at 19:35
I rephrased you question to more accurately reflect what you seem to be asking. – gWaldo Aug 1 '12 at 19:43
This type of behaviour is sometimes used in A/B testing – gWaldo Aug 1 '12 at 19:43
That is not the way to go, you're breaking HTTP, – Daniel Prata Almeida Aug 1 '12 at 19:57
I've seen this type of thing asked about before. I think that what you want to look into can be searched for as "http replay". – gWaldo Aug 1 '12 at 20:02

I don't believe you can do this with nginx by itself; a quick perusal of the relevant bits of the nginx documentation (upstream and proxy directives) doesn't suggest you can. As noted in comments, this also breaks HTTP, as there's no clarity on which of the two rear servers will respond.

One alternative is to use something like varnish and do a replay to the second rear server using varnishreplay:

I haven't used it, so I don't know if you can make it replay the traffic nearly simultaneously with the first rear server.

share|improve this answer

Use central storage like an NFS server and each nginx web node mounts the NFS share (file-level). Or use a cluster file system like OCFS2 and each web node mounts the LUN/partition (block-level).

share|improve this answer
The POST request doesn't necessarily write things to the filesystem. We need clarification on the OP's architecture. – cjc Aug 1 '12 at 19:36
@cjc, True, I was reading between the lines... – HTTP500 Aug 1 '12 at 19:37

What you want to use is something like EM-Proxy[1]. It easily handles splitting http requests across any number of servers. It also correctly handles returning data from only the live server and blocking the others so the user doesn't get multiple responses.


share|improve this answer

I was able to replicate using post_action state.

upstream main_upstream {
keepalive 1024;

server {
listen 80;
server_name _;
client_body_buffer_size 1512k;
client_max_body_size 10m;

location /1/ {
fastcgi_pass main_upstream;
post_action @replayevent ;

# Send the post_action request to a FastCGI backend for logging.
location @replayevent {

Now it send data two servers.

If your upstream do not support fastcgi (happened in my case), replace with proxy_pass.

Nginx replicate incoming post traffic to multiple upstream servers

share|improve this answer

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.