Skip to content

How to rate-limit api routes? #19

Locked Answered by singh-inder
singh-inder asked this question in Q&A
Discussion options

You must be logged in to vote

1. Update environment variables:

In supabase-automated-self-host/docker/.env file, add the following env vars:

CADDY_RATE_LIMIT_WINDOW='1m'
CADDY_RATE_LIMIT_COUNT=80

The above values will allow 80 requests/min. You can adjust the rate limit window/rate limit count acc. to your needs.
Take a look at these examples for supported time units for CADDY_RATE_LIMIT_WINDOW.

2. Update caddy service config:

In supabase-automated-self-host/docker/docker-compose.yml file, update the caddy service config:

services:
  caddy:
    container_name: caddy-container
    # 👇 UPDATED IMAGE. This is a caddy image built with caddy-ratelimit module. Repo: https://github.com/singh-inder/caddy-with-rate-limit
    i…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by singh-inder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant