I want to get as close as I can to "unit testing" Nginx rewrite rules. How close can one get to doing this? Is there a way to run the request rewriting module without running the entire web server? Can I embed the Nginx server in a process running Ruby or Python or, if I have to, Java? What tricks can you think of?
Put your rewrite rules in an include file.
Create Nginx configuration just for testing that pulls in the rewrite include file.
Using the -c
and possibly the -g
flags, Run nginx
as a user. Since you can run it on an alternate port, this won't conflict with a web server running on port 80.
Have your automated testing run tests against this "test server".
Shut down the nginx test server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With