/caddy_hasura_ratelimit

caddy server hasura and rate limiting

Primary LanguageDockerfileMIT LicenseMIT

Caddy 2.0 with ratelimit - hasura graphql

120 requests/min demo :

alt text

Pre-requisites

Build Custom Caddy image with rate limit

cd caddy-server
docker build --tag custom_caddy:0.0.1 .

Usage

  • Clone this repo on a machine with a public ip address
  • Map your domain name to this ip address
  • Edit Caddyfile and add your domain (replace <your-domain.com> with your domain, don't keep <>)
  • Edit docker-compose.yaml and change HASURA_GRAPHQL_ADMIN_SECRET to something secure
  • docker-compose up -d - execute in directory where docker-compose.yaml

Rate Limiting

  • In caddyfile change rate_limit {remote.ip} 120r/m
  • Default: 120 requets per min on ip address

GraphQL endpoint will be https://<your-domain.com>/v1/graphql Console will be available on https://<your-domain.com>/console

Connecting to External Postgres

If you want to connect to an external/existing postgres database, replace HASURA_GRAPHQL_DATABASE_URL in docker-compose.yaml with your database url.

Note: localhost will resolve to the container ip inside a docker container, not the host ip

License

MIT