Help converting from Caddy reverse_proxy rules #73

Closed
opened 2025-12-29 14:24:20 +01:00 by adam · 2 comments
Owner

Originally created by @xslim on GitHub (May 13, 2025).

I have a container (https://github.com/pocket-id/pocket-id) that internally uses Caddy with following rules in Caddyfile:

:{$CADDY_PORT:80} {
	reverse_proxy /api/* http://localhost:{$BACKEND_PORT:8080}
	reverse_proxy /.well-known/* http://localhost:{$BACKEND_PORT:8080}
	reverse_proxy /* http://localhost:{$PORT:3000}
}

How can I write godoxy label rules to match it?

Thank you!

Originally created by @xslim on GitHub (May 13, 2025). I have a container (https://github.com/pocket-id/pocket-id) that internally uses Caddy with following rules in `Caddyfile`: ```caddy :{$CADDY_PORT:80} { reverse_proxy /api/* http://localhost:{$BACKEND_PORT:8080} reverse_proxy /.well-known/* http://localhost:{$BACKEND_PORT:8080} reverse_proxy /* http://localhost:{$PORT:3000} } ``` How can I write godoxy label rules to match it? Thank you!
adam closed this issue 2025-12-29 14:24:20 +01:00
Author
Owner

@yusing commented on GitHub (May 13, 2025):

Pocket ID has Caddy built-in and listening on port 80, so you can just use that

labels:
  - proxy.#1.port=80

Or you can try this (assuming pocket-id's ports are mapped to host)

labels:
  proxy.#1.rules: |
    - on: path /api/* | path /.well-known/*
      do: proxy http://localhost:8080
    - name: default
      do: proxy http://localhost:3000

With variable substitution (planned to be implemented):

labels:
  proxy.#1.rules: |
    - on: path /api/* | path /.well-known/*
      do: proxy http://$$upstream_host:8080
    - name: default
      do: proxy http://$$upstream_host:3000
@yusing commented on GitHub (May 13, 2025): Pocket ID has Caddy built-in and listening on port 80, so you can just use that ```yaml labels: - proxy.#1.port=80 ``` Or you can try this (assuming pocket-id's ports are mapped to host) ```yaml labels: proxy.#1.rules: | - on: path /api/* | path /.well-known/* do: proxy http://localhost:8080 - name: default do: proxy http://localhost:3000 ``` With variable substitution (planned to be implemented): ```yaml labels: proxy.#1.rules: | - on: path /api/* | path /.well-known/* do: proxy http://$$upstream_host:8080 - name: default do: proxy http://$$upstream_host:3000 ```
Author
Owner

@xslim commented on GitHub (May 13, 2025):

Thank you, this helped and solved the issue:

    ports:
      - 3030:3000
      - 8030:8080
    labels:
      proxy.aliases: auth
      proxy.auth.rules: |
        - on: path /api/* | path /.well-known/*
          do: proxy http://localhost:8030
        - name: default
          do: proxy http://localhost:3030
@xslim commented on GitHub (May 13, 2025): Thank you, this helped and solved the issue: ```yml ports: - 3030:3000 - 8030:8080 labels: proxy.aliases: auth proxy.auth.rules: | - on: path /api/* | path /.well-known/* do: proxy http://localhost:8030 - name: default do: proxy http://localhost:3030 ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/godoxy-yusing#73