Adding Subdirectories


(James Hewitt) #1

I’m working my way through building up my caddyfile and I’ve run into another stopping point. I’ve looked through previous topics but I think because of my lack of knowledge I’m finding it hard to translate someone’s potentially similar issue to mine.

I have a set up that looks very similar to this:

domain.tld {
     proxy / 192.168.x.1:80 
     proxy /radarr 192.168.x.2:7878 {
          transparent
     }
}

Caddy runs and when I go to the normal domain it works but trying to go to domain.tld/radarr I just get a very basic page that says “Radarr Ver” and nothing more. Not really sure what I am doing wrong.


(Vincent) #2

Looks like you already pointed out we’re having similar issues. I was able to get at least one of my forwards to work by changing it to look like this:

domain.tld {
     proxy / 192.168.x.1:80 
     proxy /radarr 192.168.x.2:7878 {
          transparent
          without /radarr
     }
}

But unfortunately this didn’t work with Radarr. I still got got the same thing as you, “Radar Ver” and no other content.


(Matthew Fay) #3

Hi @James_Hewitt, @vincentp;

I run a usenet stack in a homelab, this is one of the most common things people run into when setting these up.

The issue is a simple one: Caddy is configured to proxy traffic to Radarr only if the URI begins with /radarr. However, Radarr itself believes it’s being served out of the web root, i.e. /. So, when it directs the client to load /main.js, /theme.css, etc, Caddy sends the request to the wrong upstream server.

Two possible fixes:

  • Set the URL base of Radarr so it knows it’s serving out of the /radarr subfolder
    (You can set this in Settings -> General, under Start Up, and requires a restart of Radarr)
  • Use a subdomain, rather than a subfolder (e.g. radarr.example.com).

Of course, the former fix requires you have access to a working Radarr to get to the settings. You can probably just load it from 192.168.x.2:7878 to toggle the setting and get it working.

The former also works on Sonarr, and NZBGet is quite permissive of directory regardless, but for other apps that don’t have a URL base setting (or similar), you’re left with using a subdomain (or trying to use http.filter to edit any links coming back from the proxy).


(James Hewitt) #4

Many thanks for your response. I’m going to try the former approach but in the interest of furthering my knowledge I thought I’d also try the subdomain approach.

I amended by original Caddyfile so it now looks like this:

domain.tld {
     proxy / 192.168.x.1:80 
}

radarr.domain.tld {
     proxy 192.168.x.2:7878 {
          transparent
     }
}

But now when I run caddy I get the following error:
Activating privacy features… 2018/06/04 21:07:36 [sonarr.domain.tld] failed to get certificate: acme: Error 403 - urn:ietf:params:acme:error:unauthorized - Invalid response from http://sonarr.domain.tld.com/.well-known/acme-challenge/xxxxx: "

404 Not Found

Not Found

<p"

what did I do wrong?


(James Hewitt) #5

Oh @Whitestrake , I meant to also say that the former method works a treat! thanks for helping me (hopefully us!)


(Matthew Fay) #6

No worries!

I’m assuming the fact that your Caddyfile says radarr but your error says sonarr is just a small mistake.

Invalid response means that LetsEncrypt connected to the server indicated by DNS and issued the challenge, but wasn’t served the challenge response.

Was DNS pointed correctly and given time to propagate? Is Caddy listening at the edge, or is another server proxying to Caddy?


(James Hewitt) #7

Sorry yes, it is just a typo. Been working with both and was editing the comment to take out sensitive information and must have typed sonarr instead of radarr.

So I have a NoIP dynamic DNS on my pfsense box, in the firewall rules I have WAN addresses port 80/443 redirect to my caddy server. The NoIP domain is something.something.com so does that mean I can’t add a further subdomain to that?

Not sure if I’m making any sense. I have the horrible habit of trying to learn lots of different things all at the same time.


(Matthew Fay) #8

You’ve hit the nail on the head (probably); pfSense will be setting the A record for the fully qualified domain name you have configured in NoIP, and not any other.

The way I got around this for my own setup was by configuring pfSense to update example.whitestrake.net and then in the Cloudflare DNS panel, adding a CNAME record for *.example.whitestrake.net pointing to example.whitestrake.net. This essentially makes Cloudflare respond to any request like example.example.whitestrake.net with the correct IP address, so I can add subdomains on the fly.