Rate_limit plugin


I’ve seen some discussion about this, for example this:

and especially this:

I’ve taken over the work by sk0g and I’ve published this:

It has to support also Header like the limit_by_header directive of caddy1 plugin.

What do you think? Thanks


Cool! Thanks for publishing that.

I’d recommend making this a caddy.Duration type, if possible, to be consistent with other timeframes in Caddy configuration:

Consider expanding on the godoc as that is what users will see when they look for documentation.

(Other than this, I haven’t given it any code review. Just a quick glance.)

Great start!

Thanks for the feedback Matt.
Do you have any code sample about using caddy.Duration in a plugin? It would help me a lot. Thanks

You just need to use the caddy.Duration type instead of int64:

And parse it like this for Caddyfile support:

Also, I strongly suggest to use ,omitempty in your json tags, because otherwise, running caddy adapt will output "window_length": 0 even if the user never explicitly configured that value.

1 Like

Thanks for the help.

I’ve updated the plugin with your suggestion: https://github.com/hundertzehn/caddy-ratelimit/commit/45bd8b186196559eac506b45aaba9affaa62f321

Best regards


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.