Nginx reverse proxy redirect

Francis Daly francis at daoine.org
Thu Aug 13 08:43:58 UTC 2020


On Wed, Aug 12, 2020 at 02:16:50AM -0400, Dr_tux wrote:

Hi there,

> I have a Nginx reverse proxy. How can I redirect it to the real server URL
> when I download mp3 files in the reverse proxy.

Make a location{} that handles mp3-file requests, and "return 301"
(or otherwise redirect) there.

> normal reverse proxy request goes to backend node, but If the url contains
> mp3, it redirects to another server.

You have something like

  location [normal reverse proxy request] {
    proxy_pass [somewhere]
  }

Add

  location [mp3 request] {
    return 301 [somewhere else]
  }

Fill in the bits in [square brackets] appropriately.

Depending on the full set of requirements, "~ mp3" or "~ mp3$" might be
a useful value for [mp3 request].

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list