3 ms·
(late reply but...) we did actually look at that; someone had a blog post about using docker for testing nginx when we did this (~3yr ago). You hit a number of
by bazzargh 9y ago
(late reply but...) we did actually look at that; someone had a blog post about using docker for testing nginx when we did this (~3yr ago). You hit a number of problems. Our nginx listened on multiple addresses and ports, which weren't equivalent - external https/http arrived on one address, internal traffic from across our clusters arrived on another, with different handling. So, we have to have docker listen on multiple addresses too, or in multiple instances. Then we have the outgoing requests, proxied to various haproxy, varnish instances, themselves on various ports. You can get round this by messing with dnsmasq and routing on your docker host...or avoid that by reorganizing all of the outgoing config so that they talk to a stub server with canned test responses. But, we had thousands of lines of handwritten nginx config as well as tens of thousands of lines of generated config...this was going to be a major effort.
And even with all that effort, it didn't give us enough information. You'd try a request on some config and scratch your head to figure out why it didn't end up being processed in the right place. Run it in the simulator though, and you'd find the exact line that had rewritten your request so it didn't reach the line of config you thought was going to kick in...
Probably the best approach would have been to patch nginx itself to add the logging we wanted, and have it handle all of those external addresses differently. The challenge there would have been getting the same depth of traceability with nginx doing things like converting rewrite rules to bytecode. But, you could probably get 80% of the way there and avoid bugs from our system not accurately re-implementing their algorithms.