Tags

mirroring http traffic

11:59am on Mar 09, 2016

Today I needed to figure out how to mirror 100% of inbound HTTP/HTTPS traffic to a second cluster of backend servers, whilst not disrupting the production traffic going to the primary cluster.

There's lots of tools to do things like this, for example duplicator and teeproxy and parallel-proxy. But those are all "code I found on the internet" and possibly questionable, and in some cases, written in node.js, which I don't know if I consider "mature" or "robust" enough for production traffic.

But there's a much better answer. nginx. It's simple:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
server {
    listen 80;

    location @mirror {
        proxy_pass http://mirror.test.com;
    }

   location / {
        proxy_pass http://primary.test.com;
        post_action @mirror;
    }
}
[RSS] [atom]
Tags