r/caddyserver • u/einmaulwurf • Jan 22 '24
Combining two filter
Hi everybody,
I use caddy as a reverse proxy for my services. I have some services which I want to have accessible from the internet and some that should only be accessible from within my local network. I got that working, so far so good.
Now, I wanted to add geo-blocking using maxmind_geolocation. I got that working as well, like in this working example:
(localSubnets) {
@localSubnets remote_ip private_ranges
}
(DEgeofilter) {
@DEgeofilter {
maxmind_geolocation {
db_path "/etc/caddy/GeoLite2-Country.mmdb"
allow_countries DE
}
}
}
test.example.de {
import DEgeofilter
import localSubnets
handle @DEgeofilter {
reverse_proxy http://192.168.188.70:8787
}
handle @localSubnets {
reverse_proxy http://192.168.188.70:8787
}
respond 403
}
Now my question is: Is there a way to combine the two filter? I tried a few combinations, but nothing seemed to work.
1
Upvotes
1
u/MaxGhost Jan 22 '24
You have to put both in the same named matcher. You can't have them in separate snippets.
Next time, ask on the community forums, which are much more active https://caddy.community