Caddy Configuration for sending 1 request to two destinations

1. Caddy version (caddy version):

Caddy1

2. How I run Caddy:

Docker image running caddy behind a proxy

a. System environment:

Unix, Docker

b. Command:

Internally within the docker entrypoint
/bin/caddy -conf /etc/company/caddy/Caddyfile -log stdout

c. Service/unit/compose file:

Unknown

d. My complete Caddyfile or JSON config:

  (disable-cors) {
    header_downstream -Access-Control-Allow-Credentials
    header_downstream -Access-Control-Allow-Origin
  }
  :80 {
    errors stdout
    log / stdout "[{when}] [PROXY] {remote} {method} :80{uri} {proto} [{status}] - {latency_ms} ms - {size} bytes - {upstream}"

    tls off

    import healthcheck
    import internal-test-proxy
  }
   (internal-test-proxy) {
    proxy /test/internal https://<custom_url_forward_connection>/ {
      import disable-cors
    }

3. The problem I’m having:

Currently we receive requests to this Caddy and the requests are forwarded to the proxy location. I had a look through the documentation without luck and was wondering if there is an approach or way to receive a request into Caddy but send 2 requests out to two different services. eg.

                         POST ServiceA: (Header X)
RequestA -> 
                         POST ServiceB: (Header Y, Header Z)

These requests should just be forwarded and don’t request any status update except Caddy returning a 200.

Requester Log:

SENT POST Sent HTTP Request to http://caddy-proxy.internal:80
RECV STATUS 200 OK

ServiceA Log:

RECV POST Sent HTTP Request to https://service-a.internal:1234
{ headers: [ header-x: abc ] }

ServiceB Log:

RECV POST Sent HTTP Request to https://service-a.internal:5678
{ headers: [ header-y: abc, header-x: abc ] }

4. Error messages and/or full log output:

5. What I already tried:

Using reverse_proxy but this only sends it to 1 of the destinations and not all of them

6. Links to relevant resources:


Any ideas if this can be accomplished with Caddy?

Caddy v1 is no longer supported, it has been EOL for over a year now. Please upgrade to Caddy v2.

If I was to upgrade to Caddy2… Is there still a way to accomplish what I’m looking for?

Not with any of the standard, included modules.

But it could be done with a custom plugin pretty easily.

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