Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Add configurable rate limit in production mode (#44)
Browse files Browse the repository at this point in the history
Signed-off-by: Emiliano Suñé <[email protected]>
  • Loading branch information
esune authored Jun 28, 2024
1 parent c809770 commit 82026a6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docker/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ APPLICATION_DOMAIN=<your-domain.test> # replace with your domain
EMAIL_CONTACT=<[email protected]> # email contact to be used for TLS certificate issuance
#CA_ENDPOINT=https://acme-v02.api.letsencrypt.org/directory
#QR_CODE_EXPIRY_SECONDS=120
#RATE_LIMIT_WINDOW=1s
#RATE_LIMIT_EVENTS=150

#Agent Settings
AGENT_NAME=Digital Age Verification Service
Expand Down
7 changes: 5 additions & 2 deletions docker/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@
# Limit request rate to avoid DDoS attacks
rate_limit {
zone dav {
match {
not path /agent/*
}
key {remote_host}
window 5s
events 15
window {$RATE_LIMIT_WINDOW}
events {$RATE_LIMIT_EVENTS}
}
}

Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ services:
- AGENT_PORT=8030
- EMAIL_CONTACT=${EMAIL_CONTACT}
- CA_ENDPOINT=${CA_ENDPOINT:-https://acme-staging-v02.api.letsencrypt.org/directory}
- RATE_LIMIT_WINDOW=${RATE_LIMIT_WINDOW:-1s}
- RATE_LIMIT_EVENTS=${RATE_LIMIT_EVENTS:-150}
volumes:
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
- ./caddy/certs:/root/.local/share/caddy/certificates
Expand Down
4 changes: 4 additions & 0 deletions docs/Docker-for-Production.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ To start from scratch and delete all existing containers and volumes, run the fo
## Production CA Authority

By default, the project is set-up to use LetsEncrypt Staging to obtain SSL certificates: when ready to run in production mode, uncomment the line specifying `CA_ENDPOINT` in the `.env` file and restart your services.

# Rate Limiting

Request rate limiting can be tweaked by using the `RATE_LIMIT_WINDOW` and `RATE_LIMIT_EVENTS` environment variables - see https://github.com/mholt/caddy-ratelimit

0 comments on commit 82026a6

Please sign in to comment.