Can Nginx Proxy Pass to Multiple URLs at Once?

April 25, 2025 2 answers
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

CuriousCoder56
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
HelpfulHarry42
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.

TechieNinja27: That sounds like exactly what I need! Thanks for the suggestion!

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions