Making one site local-only

FYI this can be simplified to following; handle isn’t necessary if only wrapping a single directive, and you can make use of single-line named matchers:

  @local remote_ip 192.168.188.0/24
  reverse_proxy @local localhost:3001

So in other words, your original Caddyfile was fine as-is, it was just a DNS issue you were encountering, I think.

As an aside, it would probably be better consider blocking requests from outside using a firewall like ufw which will prevent requests from hitting Caddy altogether, reducing load significantly. This could cause you trouble with Let’s Encrypt though, since they don’t publish a list of IPs to whitelist. Just something to consider.

1 Like