Can Nginx Proxy Pass to Multiple URLs at Once?
Asked by
TechieNinja27
I'm trying to configure Nginx to proxy requests to more than one URL simultaneously. Specifically, when hitting the `/foo` location, I want to use `proxy_pass` to send the request to both `http://foo$request_uri` and `http://bar$request_uri`. Is this possible?
Answers
It sounds like you're looking for a way to send the same request to multiple endpoints at once. Technically, Nginx isnโt built to handle sending a request to multiple URLs simultaneously in the way you might want. But if you only want to send the request to one remote and have a backup, you could leverage Nginx's upstream features to attempt connections in sequence. Check out the documentation on the upstream module for more info!
Reply to this answer
You might find what youโre looking for in the Nginx mirror module. It allows you to 'mirror' requests to another upstream server while responding from the primary one. So, it could work for your use case where you want to send the request to one server and still fire off a copy to another without worrying about the second response.
Reply to this answer
Add your answer
Answers are reviewed before publication.
TechieNinja27: That sounds like exactly what I need! Thanks for the suggestion!