Unrecognized directive: rate_limit

1. The problem I’m having:

After upgraded from 2.6.2 to 2.9.1 my Caddy file in no longer working around the 2 plugins:
rate_limit and maxmind_geolocation
for rate_limit:

2. Error messages and/or full log output:

Error: adapting config using caddyfile: /etc/caddy/Caddyfile:11: unrecognized directive: rate_limit

Error: adapting config using caddyfile: getting matcher module 'maxmind_geolocation': module not registered: http.matchers.maxmind_geolocation

3. Caddy version:

v2.9.1 h1:OEYiZ7DbCzAWVb6TNEkjRcSCRGHVoZsJinoDR/n9oaY=

4. How I installed and ran Caddy:

a. System environment:

Ubuntu 22.04.5 LTS

b. Command:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

xcaddy build --with github.com/porech/caddy-maxmind-geolocation
xcaddy build --with github.com/mholt/caddy-ratelimit

Before, I’m just update the system “sudo apt update” …
withe the same outcome

d. My complete Caddy config:


crios.bris.fr:777 {

# rate limit for all client (static_limit) and each client (dynamic_limit)
       rate_limit {
               distributed
               zone static_limit {
                       key static
                       events 100
                       window 10s
               }
               zone dynamic_limit {
                       key {remote_host}
                       events 400
                       window 1m
               }
       }

reverse_proxy 192.168.9.201:5000

}



5. Links to relevant resources:

When customizing the build after installing Caddy using the apt repo, you’re supposed to follow the instructions here:

Thanks for the answer,
I did it and it’s working for the rate_limit but not for the maxmind_geolocation

Error: adapting config using caddyfile: getting matcher module ‘maxmind_geolocation’: module not registered: http.matchers.maxmind_geolocation

I’ve reverted to the previous version of the system and used caddy-upgrade
The caddyfile was working, but the system was
and after:

sudo apt update
sudo apt full-upgrade

and the error happened

So I’ve reinstalled caddy and the 2 plugins with no success
=> same error

Error: adapting config using caddyfile: getting matcher module ‘maxmind_geolocation’: module not registered: http.matchers.maxmind_geolocation

Try this instead:

xcaddy build \
   --with github.com/porech/caddy-maxmind-geolocation \
   --with github.com/mholt/caddy-ratelimit

If you run multiple xcaddy build commands, the latter one overrides the former one. You need to list all plugins within the same xcaddy build.

1 Like

Thanks for your help.
It works well :pray:

1 Like