How to get traefik to redirect to specific non-docker port from inside docker

后端 未结 2 1385
时光取名叫无心
时光取名叫无心 2021-02-01 07:09

First of all I\'m sorry if I\'m not using the right terms to ask this question, but I\'m not up to the terminology in place.

I have traefik running in a docker container

2条回答
  •  离开以前
    2021-02-01 07:44

    I've fiddled around and found the answer.

    In traefik.toml add:

    ################################################################
    # File configuration backend
    ################################################################
    # Enable file configuration backend
    # Optional
    [file]
            filename = "servers.toml"
    
    # Enable watch file changes
            watch = true
    

    In docker-compose.yml change the volumes: to:

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${SERVER_DIR}/AppData/traefik:/etc/traefik/
      - ${PWD}/acme.json:/acme.json
      - ${PWD}/traefik.toml:/etc/traefik/traefik.toml
      - ${PWD}/servers.toml:/servers.toml
    

    Add file servers.toml:

    loglevel = "ERROR"
    
    [backends]
    [backends.nasweb]
            [backends.nasweb.servers.nasweb]
                url = "http://192.168.1.11:8080"
    
    [frontends]
            [frontends.domain]
                    backend = "nasweb"
            [frontends.domain.routes.domain]
                    rule = "Host:www.myserver.com"
    

提交回复
热议问题