mholt / caddy-ratelimit

HTTP rate limiting module for Caddy 2
Apache License 2.0
210 stars 15 forks source link

Rate limit based on path, but doesn't work #18

Closed Likenttt closed 2 months ago

Likenttt commented 1 year ago

Hi, I wanna do rate limit based on the host + path, but the config below didn't work.

{
        order rate_limit before basicauth
}

https://example.com {
        rate_limit {
                distributed
                zone dynamic_example {
                        key {remote_host}
                        events 1000
                        window 60s
                }
                zone pair_api {
                       match {
                               path /api/auth/pair
                       }
                       key {remote_host}/api/auth/pair
                       events 1
                       window 10s
                }
        }
}
zone pair_api {
       match {
               path /api/auth/pair
       }
       key {remote_host}/api/auth/pair
       events 1
       window 10s
}

I followed this instruction

Each zone may optionally filter the requests it applies to by specifying request matchers.

Anything wrong about this snippet? Thanks in advance

mholt commented 1 year ago

Note that matchers in zones via the Caddyfile are not yet implemented:

PLANNED:

  • Ability to define matchers in zones with Caddyfile

You'll have to use the JSON config for that for now. Sorry! It's something I can prioritize if a company would like to sponsor that.

Likenttt commented 1 year ago

Note that matchers in zones via the Caddyfile are not yet implemented:

PLANNED:

  • Ability to define matchers in zones with Caddyfile

You'll have to use the JSON config for that for now. Sorry! It's something I can prioritize if a company would like to sponsor that.

Sorry, I didn't know the term a matcher in zones. Now I got it.

How to buy you a beer or coffee

mholt commented 1 year ago

(No worries, I didn't specify very clearly.)

Ha, I don't drink either of those actually :upside_down_face: I appreciate the thought, maybe see if your company would like to sponsor the Caddy project -- we're aiming to grow our community and maintainers!

Thank you :slightly_smiling_face:

tasiotas commented 7 months ago

also looking forward to this feature 😍

muety commented 3 months ago

Would love to have this!

mholt commented 3 months ago

Will reopen since it looks like people want Caddyfile config specifically -- I can prioritize this with a sufficient sponsorship.