Reverse proxy and rewrite (newbie question)

I am using caddy as the reverse proxy to a application server. This is fine.
But to some path on request I need the files server from disk.

So if some one access :

https://www.mydomain.com/x/y/z

It must be redirected to the reverse proxy.

But if someone access :

https://www.mydomain.com/audio/myaudio.wav

The file myaudio.wav must be served from the file /opt/audio
Of couse the dir /opt/audio contains myaudio.wav

So if the accessed url starts with /audio the content is server from the directory otherwise it goes to the reverse proxy.

I try to use rewrite directive but I am missing something.

Hi @danilolr,

You can use the except subdirective to declare a base path not to proxy from, like except /audio.

  • except is a space-separated list of paths to exclude from proxying. Requests that match any of ignored_paths will be passed thru.

https://caddyserver.com/docs/proxy

Hi @Whitestrake this solved my use case right now. Thanks.
I did create an except to audio and set root to the parent directory of the audio dir.
So it is working fine.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.