1. Caddy version (caddy version
):
2.2.1
2. How I run Caddy:
systemd
a. System environment:
debian 10 systemd
b. Command:
paste command here
c. Service/unit/compose file:
# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# See https://caddyserver.com/docs/install for instructions.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddyfile or JSON config:
{
email "wschenk@gmail.com"
}
faas.willschenk.com {
@proxy {
path /ui/*
path /system/*
path /function/*
}
reverse_proxy @proxy http://localhost:8080
rewrite not { @proxy } /function/web/{uri}
}
3. The problem I’m having:
I want to have three paths reversed proxied to http://localhost:8080 and then everything else rewritten to /function/web/{uri}, so that it will get reversed proxied.
I attempted to have a not
matcher to be the inverse of the @proxy
named matcher, but I don’t think that works.
If I put rewrite / /function/web
it will not see the reverse proxy statement and then rewrite forever. What I expect is to have the rewrite rule rewrite, and then the first rule (higher up in the file) to then proxy it.
I find the documentation for Caddy 2 to be super confusing. What is a matcher, where can I use it? What is the json file? How is that different from the Caddyfile
?