I’m trying to geoblock the landing page of my website outside of my country and leave the path /shares/* open to all countries.
For that purpose I’m using caddy-maxmind-geolocation module. I’m able to geoblock but everything is geoblocked even with the configuration I currently have.
2. Error messages and/or full log output:
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
INF ts=1741728082.7687137 msg=using config from file file=/etc/caddy/Caddyfile
Error: adapting config using caddyfile: parsing caddyfile tokens for 'handle': unrecognized directive: maxmind_geolocation - are you sure your Caddyfile structure (nesting and braces) is correct?, at /etc/caddy/Caddyfile:62
Edit:
Sorry for the confusion but it was actually working as I had before in my initial message, but I misunderstood how the “wildcard” * works in there apparently.
I thought
/shares/*
would include all subpaths under /shares, so if I had /shares/whatever/ it’d still fall under the allow all countries. But what was happening is that only /shares/ was being allowed to all countries.
Now the question is, how does it work and how can I have it be all subpaths under /share/ ?
I’ve tried so many things but I can’t get it to work, only
example.com/shares
is unblocked, everything else is blocked, even
example.com/shares/something
is also blocked.
From my understanding if you leave path empty after “handle” it defaults to * which means it’ll handle the whole domain and I think that’s what is happening to everything other than
path matching is exact unless you use astrisk (wildcard). We typically recommend doing something like this to ensure consistency when handling sensitive edges:
everything except for /shares/ gets blocked everywhere, including my own country, /shares/whatever/ can’t be accessed anywhere either.
Only /shares/ becomes accessible, everything else gets blocked in all countries including mine.
then everything except for /shares/ gets blocked outside of my country, the geoip filter works and everything is accessible in my country. Problem is I have links that are generated with /share/whatever that I’d need being accessed all over the world and with either of these setups they’re not.
It is solved, I was missing some paths for the webserver to make it function, that’s why it was not showing when I added the / to it.
The paths were working as intended, it was just me being a noob.