caddy-docker-proxy icon indicating copy to clipboard operation
caddy-docker-proxy copied to clipboard

Multiple subdomains, same container, different ports

Open pax-k opened this issue 2 years ago • 1 comments

How can I proxy multiple ports of the same container to different subdomains?

Currently I'm proxying just one of the exposed ports, but I would like to proxy the second port as well, on a different subdomain.

If not possible on a different subdomain, at least on a different path, or the same subdomain but indicating the port.

Anyway https://subdomain-1.myhost.com should always resolve to 1001

ports:
      - mode: host
        protocol: tcp
        published: 1001
        target: 1001
      - mode: host
        protocol: tcp
        published: 1002
        target: 1002
    expose:
      - "1001"
      - "1002"
    networks:
      - caddy
    labels:
      caddy: subdomain-1.myhost.com
      caddy.reverse_proxy: "{{upstreams 1001}}

How could I proxy 1002 without spinning a second container ?

Thank you!

LATER:

I was partially able to proxy it like this:

labels:
      caddy_0: subdomain-1.myhost.com
      caddy_0.reverse_proxy: "{{upstreams 1001}}
      caddy_1: subdomain-2.myhost.com
      caddy_1.reverse_proxy: "{{upstreams 1002}}

But the service running on https://subdomain-2.myhost.com now says "This server only accepts secure HTTPS connections.", even if I'm on HTTPS.

pax-k avatar Feb 02 '23 21:02 pax-k

I'm using it with minio, and it working fine:

    deploy:
      labels:
        caddy_0: minio.mydomain.com
        caddy_0.reverse_proxy: "{{upstreams 9000}}"
        caddy_1: minio-console.mydomain.com
        caddy_1.reverse_proxy: "{{upstreams 9001}}"

Maybe is something specific of your application @pax-k

ettoreleandrotognoli avatar Aug 22 '24 18:08 ettoreleandrotognoli