Only expose virtualhost to specific website

1. Caddy version (caddy version):

v2.4.1

2. How I run Caddy:

I run Caddy using a Caddyfile-formatted configuration, and the standard debian-provided systemd configuration.

a. System environment:

Debian 10 x64, SystemD

d. My complete Caddyfile or JSON config:

http://paste.artemix.org, https://paste.artemix.org {
  tls {
    on_demand
  }
  encode zstd gzip
  reverse_proxy http://localhost:1234
}
http://monitor.home {
  bind 10.0.0.254
  reverse_proxy http://localhost:5555
}
http://dashboard.home {
  bind 10.0.0.254
  reverse_proxy http://localhost:5556
}

3. The problem I’m having:

I am trying to expose a few virtual hosts to only users from within my VPN’s network (and localhost), but I have found absolutely nothing on how to realize this.

4. Error messages and/or full log output:

Jun 04 10:29:11 Styx caddy[699]: run: loading initial config: loading new config: http app module: start: tcp: listening on :443: listen tcp :443: bind: address already in use

5. What I already tried:

I’ve tried to use the bind clause to only expose some virtual hosts to my VPN’s interface, but that failed, saying that it was already being used (ie that I could only use it for one virtual host).

http://monitor.home {
    bind 127.0.0.1 10.0.0.254
}
http://dashboard.home {
    bind 127.0.0.1 10.0.0.254
}

I have found no other workaround that could help me in the documentation or forums.

6. Links to relevant resources:

You can use the remote_ip matcher instead, to only allow requests from private IPs.

@notPrivate not remote_ip 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8
respond @notPrivate "No soup for you" 403

Would it be possible to completely drop the connection instead of HTTP-handling it?

Yep, with the abort directive:

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.