Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I create Docker labels for caddy-l4? #702

Open
rubyon opened this issue Feb 5, 2025 · 1 comment
Open

How do I create Docker labels for caddy-l4? #702

rubyon opened this issue Feb 5, 2025 · 1 comment

Comments

@rubyon
Copy link

rubyon commented Feb 5, 2025

ARG CADDY_VERSION=2.9.1
FROM caddy:${CADDY_VERSION}-builder AS builder

RUN xcaddy build \
    --with github.com/lucaslorentz/caddy-docker-proxy/v2 \
    --with github.com/mholt/caddy-l4=github.com/vnxme/caddy-l4@caddyfile

FROM caddy:${CADDY_VERSION}-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

CMD ["caddy", "docker-proxy"]
❯ cat Dockerfile
ARG CADDY_VERSION=2.9.1
FROM caddy:${CADDY_VERSION}-builder AS builder

RUN xcaddy build \
    --with github.com/lucaslorentz/caddy-docker-proxy/v2 \
    --with github.com/mholt/caddy-l4=github.com/vnxme/caddy-l4@caddyfile

FROM caddy:${CADDY_VERSION}-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

CMD ["caddy", "docker-proxy"]

I created an image by writing a Dockerfile as above.

What I want is for SSH connection requests to ssh.test.com to be forwarded to the port 22 of a specific container.

Currently, caddy-docker-proxy is configured as follows:

services:
  caddy:
    container_name: caddy
    image: my/caddy-docker-proxy-l4
    restart: unless-stopped
    environment:
      - CADDY_INGRESS_NETWORKS=caddy
    networks:
      - caddy
    ports:
      - 22:22
      - 80:80
      - 443:443

...
@rubyon
Copy link
Author

rubyon commented Feb 5, 2025

      caddy_16.layer4.:22.@git: ssh
      caddy_16.layer4.:22.route: "@git"
      caddy_16.layer4.:22.route.proxy.upstream: gitea:22

I have successfully configured my caddy-docker-proxy container using labels as described above.

However, I am wondering if the following setup is possible:

For example:
• When connecting to gitea.domain.com, it should proxy to gitea:22.
• When connecting to test.domain.com, it should proxy to test:22.

Is it possible to route SSH traffic this way using caddy-docker-proxy?
I would appreciate any advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant