Trying out Caddy as a reverse proxy for Sonarr and Radarr

I wanted to play with Caddy and thought I’d try setting it up as a reverse proxy for my Sonarr and Radarr installations. I went with install Caddy on my Raspberry Pi directly than using Docker. The official Download link was confusing, so better to go via the Download link in the official Docs. Here’s the link for Raspberry Pi OS and Debian etc.

I modified the default Caddyfile to be this:

The idea being stuff.rakhesh.home port 80 is where Caddy is running; I want /radarr/* and /sonarr/* to reverse proxy to my Radarr & Sonarr installs running on a different server; and I also want to redirect any requests to /radarr or /sonarr to the corresponding one with a “/” added.

I left the default config of file_server and root as is. The default config doesn’t have a site block like stuff.rakhesh.home:80 { ... } because it has a single site. I too currently have a single site but thought of making a site block just to be clear.

This config doesn’t work. :) If I go to http://stuff.rakhesh.home/radarr I get taken to http://stuff.rakhesh.home/login?returnUrl=/radarr/. That’s coz of the subfolder problem, well explained in this Caddy Wiki page. The issue is that Radarr expects me to login and redirects http://stuff.rakhesh.home/radarr to its login page, but since that login page doesn’t start with /radarr Caddy doesn’t know it should proxy me to the Radarr backend.

Luckily for us Radarr and Sonarr have an option to specify the base URL. So I head over to Radarr and added the following under Settings > General > URL Base: radarr/.

Then I restarted Radarr.

What this does is that whereas previously Radarr was available at http://pi0.rakhesh.home:8080/ it is now available at http://pi0.rakhesh.home:8080/radarr.

I did the same for Sonarr too.

Now if I go to http://stuff.rakhesh.home/radarr I am taken to http://stuff.rakhesh.home/radarr/login?returnUrl=/radarr/. Since the URL has a /radarr in it Caddy correctly sends the request to Radarr for the login page, and it displays as expected. I can login successfully and the page works fine. Yay.