Search code examples
dnsportforwardingcaddycaddyfile

Caddy multi-domain reverse proxy


I'm new to Caddy server but their website looked promising. I want to use it as a reverse proxy for the websites that are hosted on other servers. So, I have 2 websites; a Wiki and a photo gallery, that needs to be hosted outside of my local network.

Caddyfile

My Caddyfile is pretty straight forward:

coppery.<my domain name> {
  proxy / http://192.168.1.66:80 {
    transparent
  }
}

wiki.<my domain name> {
  proxy / http://192.168.1.88:8080 {
    transparent
  }
}

When I first started caddy I saw some HTTPS stuff with lets encrypt but that was succesful so now when I start it I get this output:

root@caddy:~# caddy 
Activating privacy features... done.

Serving HTTPS on port 443 
https://coppery.<my domain name>
https://wiki.<my domain name>


Serving HTTP on port 80 
http://coppery.<my domain name>
http://wiki.<my domain name>

WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with `ulimit -n 8192`.

I think for now I can dismiss the warning, I might solve that in the future but this is not a production environment anyway.

Portforwarding and DNS

I configured the domain names to resolve to my IP address (this already worked) and when I ping the domain names, they resolve the IP address correctly.

When I access the IP-addresses directly from my local network it works, I get the websites I expect. So I added some configuration on my router and port forwarded port 80 and 443 to the local IP address of the machine hosting the Caddy server.

Now when I try to access coppery.<my domain name> on either HTTP or HTTPS it's not showing anything.

So my only guess is that there is something wrong with the Caddyfile configuration but it's a realy simple case and all I've done is using the examples I found online. Which don't seem to work.

So the question is: What am I missing to make this work as intended?


Solution

  • The problem was the DNS. Once I configured the domain names in my local host file it worked. So the configuration in my question is all correct.