Code Monkey home page Code Monkey logo

Comments (7)

francislavoie avatar francislavoie commented on July 30, 2024 1

There's no such thing as global HTTP routes in Caddy. All HTTP routes must go within a site block.

from caddy-docker-proxy.

francislavoie avatar francislavoie commented on July 30, 2024

Yes, to add additional plugins you need to write your own Dockerfile. See the README for an example. https://github.com/lucaslorentz/caddy-docker-proxy?tab=readme-ov-file#custom-images

from caddy-docker-proxy.

sowinski avatar sowinski commented on July 30, 2024

Hi @francislavoie, I build my own image and I can see that is successfully build with this module.
(Here you can my Dockerfile: #626 (comment))

If I run locally my setup with a static defined route it works fine:

This is my Caddyfile for my local setup:

{
    auto_https off
	order rate_limit before basicauth
}

:80
rate_limit {
	distributed
	zone dynamic_global {
		key    {remote_host}
		window 60s
		events 75
	}
}

whoami.example.com:80 {
    reverse_proxy 172.22.0.3:80
}

But if I want to use this in production with the caddy-docker-proxy container "discovery" functionality with labels it is not working.
Dockerfile for production:

{
	order rate_limit before basicauth
}

:80
rate_limit {
	distributed
	zone dynamic_global {
		key    {remote_host}
		window 60s
		events 75
	}
}

And is an example service with my labels

...
labels:
      caddy: "www.example.com"
      caddy.log:
      caddy.reverse_proxy: "{{upstreams 8000}}"
      caddy.encode: "gzip"
...

Have you or someone else ever successfully used caddy-docker-proxy with the rate-limit plugin?
(https://github.com/mholt/caddy-ratelimit)

from caddy-docker-proxy.

francislavoie avatar francislavoie commented on July 30, 2024

Rate limit is a directive so it must go within a site block. You can't put it top level, otherwise Caddy will parse it as a site address. If you have two sites, then braces are required. If you use labels, then rate_limit is just another directive, like reverse_proxy etc.

from caddy-docker-proxy.

sowinski avatar sowinski commented on July 30, 2024

@francislavoie
So I can not set a global rate limit for all https calls? I need to add it to all container manually with labels?

from caddy-docker-proxy.

sowinski avatar sowinski commented on July 30, 2024

Rate limit is a directive so it must go within a site block.
This is what you mean correct? To add it separately in each docker compose over labels?

Can you confirm that it is not possible to add a global rate limit for all containers/services in the main Caddyfile?

version: '3.7'
services:
  whoami:
    image: traefik/whoami
    networks:
      - caddy
    labels:
      caddy: "whoami.example.com"
      caddy.reverse_proxy: "{{upstreams 80}}"
      caddy.tls: "internal"
      caddy.rate_limit.distributed:
      caddy.rate_limit.zone: "dynamic_global"
      caddy.rate_limit.zone.key: "{remote_host}"
      caddy.rate_limit.zone.window: "1s"
      caddy.rate_limit.zone.events: "1"

networks:
  caddy:
    external: true

from caddy-docker-proxy.

sowinski avatar sowinski commented on July 30, 2024

@francislavoie Thank you!

from caddy-docker-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.