Cool, looks good!
What wildcard feature are you referring to, exactly?
Other than that, your Caddyfile looks quite efficient!
If you wanted to be super pedantic, you could reduce the line count by inverting the matcher logic. Because respond
operates before reverse_proxy
does (see: Caddyfile Directives — Caddy Documentation), you can rely on it to terminate the request before the proxy happens. The line count is reduced because you don’t need to open a handle
block for the reverse proxy to “beat” the responder.
example.com {
@external {
not remote_ip 192.168.0.0/16
}
respond @external 403
reverse_proxy 127.0.0.1:9000
}
But the downside there is where your current logic is more safe (it only allows access if it confirms an internal remote), the other is technically less safe (it only denies access if it confirms external remote). The same in practice, perhaps, but the difference is accessible-by-default vs. inaccessible-by-default. I’d probably just keep what you have.
Welcome to IT as a hobby!
Inline code like this
is done by quoting with single backticks (`) either side of the text.
Entire scrolling blocks can be created with triple backticks (```) like so (the text
part just disables any syntax highlighting, it’s not necessary):
Or you can select all the code/log/whatever text and hit this button on the editor: