Use same domainname but with different port

Hi there,

First time poster here. I am trying to create a specific situation which I don't seem to get fully operational.

Can anybody tell me how to create the following situation:

thisismydomain.com (443) -> dockercontainerweb1
thisismydomain.com:8081 -> dockercontainerweb/service2

So I have a basic webserver running that is reachable with SSL when entering the url. But I also want to expose another service that runs on a different container but with the same URL by entering the desired portnumber.

Define the entrypoints and ensure your routers use the right entrypoints.

version: '3.8'
services:
  traefik:
    image: traefik
    ports:
      - 443:443
      - 8081:8081
    command:
      - '--api'
      - '--providers.docker.exposedByDefault=false'
      - '--entrypoints.webalt.address=:8081'
      - '--entrypoints.webalt.http.tls=true'
      - '--entrypoints.websecure.address=:443'
      - '--entrypoints.websecure.http.tls=true'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      traefik.enable: true
      traefik.http.routers.traefik.rule: Host(`traefik.localhost`)
      traefik.http.routers.traefik.entrypoints: websecure
      traefik.http.routers.traefik.service: api@internal

  whoami-one:
    image: traefik/whoami
    command:
      - -name=one
    labels:
      traefik.enable: true
      traefik.http.routers.one.rule: Host(`one.localhost`)
      traefik.http.routers.one.entrypoints: websecure

  whoami-two:
    image: traefik/whoami
    command:
      - -name=two
    labels:
      traefik.enable: true
      traefik.http.routers.two.rule: Host(`one.localhost`)
      traefik.http.routers.two.entrypoints: webalt

Thank you very mutch. Everything is working now!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.