Docker-compose basic example from docs.traefik.io not working

Hi,

I tried the example at https://docs.traefik.io/user-guides/docker-compose/basic-example/ but can't get it to work.

What I did:

  1. Created docker-compose.xml with the content mentioned in the documentation
  2. uncomment - "--log.level=DEBUG"
  3. set Host(test.internaldns.com)" (the is only a placeholder the real internal DNS works and resolves to the docker host)
  4. docker-compose up
  5. in another shell curl -i http://test.internaldns.com

What I see:

  1. as soon as i start the curl command I see output in the docker-compose terminal in the form of always two log lines.
traefik    | time="2019-11-28T11:59:43Z" level=debug msg="vulcand/oxy/roundrobin/rr: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.65.3\"],\"X-Forwarded-Host\":[\"test.internaldns.com\"],\"X-Forwarded-Port\":[\"80\"],\"X-Forwarded-Proto\":[\"http\"],\"X-Forwarded-Server\":[\"23f1c5460c0c\"],\"X-Real-Ip\":[\"10.0.0.2\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"test.internaldns.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"10.0.0.2:33838\",\"RequestURI\":\"/\",\"TLS\":null}"
traefik    | time="2019-11-28T11:59:43Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.65.3\"],\"X-Forwarded-Host\":[\"test.internaldns.com\"],\"X-Forwarded-Port\":[\"80\"],\"X-Forwarded-Proto\":[\"http\"],\"X-Forwarded-Server\":[\"23f1c5460c0c\"],\"X-Real-Ip\":[\"10.0.0.2\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"test.internaldns.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"10.0.0.2:33838\",\"RequestURI\":\"/\",\"TLS\":null}" ForwardURL="http://172.20.0.3:80"
  1. I have to kill the the docker-compose command to make it stop. Killing the curl command does nothing.

  2. as soon as I kill the docker compose-command I see the following in the curl shell as output

curl -i  http://test.internaldns.com
HTTP/1.1 502 Bad Gateway
Cache-Control: no-cache
Content-Length: 1425
Content-Type: text/html
Date: Thu, 28 Nov 2019 12:13:24 GMT
Connection: close

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="de" lang="de" xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">

<!--Head-->
<head>
  <meta content="IE=11.0000" http-equiv="X-UA-Compatible">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>McAfee Web Gateway - Notification</title>
  <script src="/mwg-internal/de5fs23hu73ds/files/javascript/sw.js" type="text/javascript" ></script>
  <link rel="stylesheet" href="/mwg-internal/de5fs23hu73ds/files/default/web.css" />
</head>
<!--/Head-->
<!--Body-->
<body  onload="swOnLoad();" class="background">
<div class="inner_frame">
<div class="head_right_text">
<img alt="Logo" class="emblem" src='/mwg-internal/de5fs23hu73ds/files/default/img/logo.png'>
</div>

<img alt="Logo" class="lion_left" src='/mwg-internal/de5fs23hu73ds/files/default/img/bg_loewe_links.png'>
<img alt="Logo" class="lion_right" src='/mwg-internal/de5fs23hu73ds/files/default/img/bg_loewe_rechts.png'>

<!--Contents-->
<div class="msg_border">
<div class="msg_head">
Keine Verbindung m&ouml;glich.
</div>
<div class="msg_text">

<p>
The proxy has received an unknown command. 
</p>
</div>
</div>

<!--/Contents-->
</div>
</body>
<!--/Body-->
</html>

This seems to come from our corporate proxy which i had to set to get the docker images from docker hub.
The proxy is set via systemd Environment

$ cat /etc/systemd/system/docker.service.d/proxy.conf
[Service]
Environment="HTTP_PROXY=http://proxy.internaldns.com:80"
Environment="HTTPS_PROXY=http:/proxy.internaldns.com:80"

Docker runs on an Ubuntu 19.10 in version 19.03.3, build a872fc2f86

Is it not possible to run traefik with a corporate proxy set in docker?
Did I miss something?

The docker-compose.xml in full

cat docker-compose.yml
version: "3.3"

services:

  traefik:
    image: "traefik:v2.0.0-rc3"
    container_name: "traefik"
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  whoami:
    image: "containous/whoami"
    container_name: "simple-service"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`test.internaldns.com`)"
      - "traefik.http.routers.whoami.entrypoints=web"

Output of docker-compose up command

$ docker-compose up
Creating traefik        ... done
Creating simple-service ... done
Attaching to traefik, simple-service
simple-service | Starting up on port 80
traefik    | time="2019-11-28T11:59:27Z" level=info msg="Configuration loaded from flags."
traefik    | time="2019-11-28T11:59:27Z" level=info msg="Traefik version 2.0.0-rc3 built on 2019-09-10T17:10:04Z"
traefik    | time="2019-11-28T11:59:27Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"traefik\":{\"address\":\":8080\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}},\"web\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}},\"api\":{\"insecure\":true,\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"}}"
traefik    | time="2019-11-28T11:59:27Z" level=error msg="\nYou haven't specified the sendAnonymousUsage option, it will be enabled by default.\n"
traefik    | time="2019-11-28T11:59:27Z" level=info msg="\nStats collection is enabled.\nMany thanks for contributing to Traefik's improvement by allowing us to receive anonymous information from your configuration.\nHelp us improve Traefik by leaving this feature on :)\nMore details on: https://docs.traefik.io/v2.0/contributing/data-collection/\n"
traefik    | time="2019-11-28T11:59:28Z" level=debug msg="No default certificate, generating one"
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Start TCP Server" entryPointName=traefik
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Start TCP Server" entryPointName=web
traefik    | time="2019-11-28T11:59:29Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
traefik    | time="2019-11-28T11:59:29Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}"
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Provider connection established with docker 19.03.3 (API 1.40)" providerName=docker
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Filtering disabled container" providerName=docker container=traefik_traefik2-23f1c5460c0c5a1e8190fe3c3df714afab4f33e058ce6c117b770e15c947f403
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"whoami\":{\"entryPoints\":[\"web\"],\"service\":\"whoami_traefik2\",\"rule\":\"Host(`test.internaldns.com`)\"}},\"services\":{\"whoami_traefik2\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.20.0.3:80\"}],\"passHostHeader\":true}}}},\"tcp\":{}}" providerName=docker
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Creating middleware" entryPointName=web routerName=whoami@docker serviceName=whoami_traefik2 middlewareName=pipelining middlewareType=Pipelining
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Creating load-balancer" entryPointName=web routerName=whoami@docker serviceName=whoami_traefik2
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Creating server 0 http://172.20.0.3:80" routerName=whoami@docker serviceName=whoami_traefik2 entryPointName=web serverName=0
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Added outgoing tracing middleware whoami_traefik2" middlewareType=TracingForwarder entryPointName=web routerName=whoami@docker middlewareName=tracing
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="Creating middleware" entryPointName=web middlewareName=traefik-internal-recovery middlewareType=Recovery
traefik    | time="2019-11-28T11:59:29Z" level=debug msg="No default certificate, generating one"
traefik    | time="2019-11-28T11:59:43Z" level=debug msg="vulcand/oxy/roundrobin/rr: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.65.3\"],\"X-Forwarded-Host\":[\"test.internaldns.com\"],\"X-Forwarded-Port\":[\"80\"],\"X-Forwarded-Proto\":[\"http\"],\"X-Forwarded-Server\":[\"23f1c5460c0c\"],\"X-Real-Ip\":[\"10.0.0.2\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"test.internaldns.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"10.0.0.2:33838\",\"RequestURI\":\"/\",\"TLS\":null}"
traefik    | time="2019-11-28T11:59:43Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.65.3\"],\"X-Forwarded-Host\":[\"test.internaldns.com\"],\"X-Forwarded-Port\":[\"80\"],\"X-Forwarded-Proto\":[\"http\"],\"X-Forwarded-Server\":[\"23f1c5460c0c\"],\"X-Real-Ip\":[\"10.0.0.2\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"test.internaldns.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"10.0.0.2:33838\",\"RequestURI\":\"/\",\"TLS\":null}" ForwardURL="http://172.20.0.3:80"
traefik    | time="2019-11-28T11:59:43Z" level=debug msg="vulcand/oxy/roundrobin/rr: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"Accept-Encoding\":[\"gzip\"],\"Connection\":[\"Keep-Alive\"],\"User-Agent\":[\"curl/7.65.3\"],\"X-Forwarded-Host\":[\"test.internaldns.com\"],\"X-Forwarded-Port\":[\"80\"],\"X-Forwarded-Proto\":[\"http\"],\"X-Forwarded-Server\":[\"23f1c5460c0c\"],\"X-Real-Ip\":[\"10.167.16.21\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"test.internaldns.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"10.167.16.21:60544\",\"RequestURI\":\"/\",\"TLS\":null}"
...
traefik    | time="2019-11-28T11:59:44Z" level=debug msg="vulcand/oxy/roundrobin/rr: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"Accept-Encoding\":[\"gzip\"],\"Connection\":[\"Keep-Alive\"],\"User-Agent\":[\"curl/7.65.3\"],\"X-Forwarded-Host\":[\"test.internaldns.com\"],\"X-Forwarded-Port\":[\"80\"],\"X-Forwarded-Proto\":[\"http\"],\"X-Forwarded-Server\":[\"23f1c5460c0c\"],\"X-Real-Ip\":[\"10.167.16.21\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"test.internaldns.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"10.167.16.21:24772\",\"RequestURI\":\"/\",\"TLS\":null}"
traefik    | time="2019-11-28T11:59:44Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"Accept-Encoding\":[\"gzip\"],\"Connection\":[\"Keep-Alive\"],\"User-Agent\":[\"curl/7.65.3\"],\"X-Forwarded-Host\":[\"test.internaldns.com\"],\"X-Forwarded-Port\":[\"80\"],\"X-Forwarded-Proto\":[\"http\"],\"X-Forwarded-Server\":[\"23f1c5460c0c\"],\"X-Real-Ip\":[\"10.167.16.21\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"test.internaldns.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"10.167.16.21:24772\",\"RequestURI\":\"/\",\"TLS\":null}" ForwardURL="http://172.20.0.3:80"
^CGracefully stopping... (press Ctrl+C again to force)
Stopping simple-service ... done
Stopping traefik        ... done
$ docker inspect traefik
[
    {
        "Id": "23f1c5460c0c5a1e8190fe3c3df714afab4f33e058ce6c117b770e15c947f403",
        "Created": "2019-11-28T11:59:26.6936603Z",
        "Path": "/traefik",
        "Args": [
            "--log.level=DEBUG",
            "--api.insecure=true",
            "--providers.docker=true",
            "--providers.docker.exposedbydefault=false",
            "--entrypoints.web.address=:80"
        ],
        "State": {
            "Status": "exited",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2019-11-28T12:13:17.7359791Z",
            "FinishedAt": "2019-11-28T12:13:25.2789768Z"
        },
        "Image": "sha256:ef13aaf30be0e65904225c223c7bbf5138a1c9391a2192c8380cb4054cd1b23b",
        "ResolvConfPath": "/var/lib/docker/containers/23f1c5460c0c5a1e8190fe3c3df714afab4f33e058ce6c117b770e15c947f403/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/23f1c5460c0c5a1e8190fe3c3df714afab4f33e058ce6c117b770e15c947f403/hostname",
        "HostsPath": "/var/lib/docker/containers/23f1c5460c0c5a1e8190fe3c3df714afab4f33e058ce6c117b770e15c947f403/hosts",
        "LogPath": "/var/lib/docker/containers/23f1c5460c0c5a1e8190fe3c3df714afab4f33e058ce6c117b770e15c947f403/23f1c5460c0c5a1e8190fe3c3df714afab4f33e058ce6c117b770e15c947f403-json.log",
        "Name": "/traefik",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/var/run/docker.sock:/var/run/docker.sock:ro"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "traefik2_default",
            "PortBindings": {
                "80/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "80"
                    }
                ],
                "8080/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8080"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Capabilities": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/ece5ee4c481264231f2497c70c09cf210d6da2794b85b230d697d9c7539dc752-init/diff:/var/lib/docker/overlay2/3d97a5bbd0b443ed2c1dde4e36f47eed26803626d199d3f4bb9506c93a65820c/diff:/var/lib/docker/overlay2/af17930857860415797113c3a6f9397898237760f317816f2e740baa35d653ef/diff:/var/lib/docker/overlay2/fccb330ad924a0e0213ac071b9f19fdd84837d22a14208ebbc3f0ed2df274149/diff",
                "MergedDir": "/var/lib/docker/overlay2/ece5ee4c481264231f2497c70c09cf210d6da2794b85b230d697d9c7539dc752/merged",
                "UpperDir": "/var/lib/docker/overlay2/ece5ee4c481264231f2497c70c09cf210d6da2794b85b230d697d9c7539dc752/diff",
                "WorkDir": "/var/lib/docker/overlay2/ece5ee4c481264231f2497c70c09cf210d6da2794b85b230d697d9c7539dc752/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/var/run/docker.sock",
                "Destination": "/var/run/docker.sock",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "volume",
                "Name": "bbf557c120a16cd0243006e1015be58299969b4627644175dcc81d8a82f1a7d4",
                "Source": "/var/lib/docker/volumes/bbf557c120a16cd0243006e1015be58299969b4627644175dcc81d8a82f1a7d4/_data",
                "Destination": "/tmp",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "23f1c5460c0c",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {},
                "8080/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "HTTP_PROXY=http://proxy.internaldns.com:80",
                "http_proxy=http://proxy.internaldns.com:80",
                "HTTPS_PROXY=http://proxy.internaldns.com:80",
                "https_proxy=http://proxy.internaldns.com:80",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "--log.level=DEBUG",
                "--api.insecure=true",
                "--providers.docker=true",
                "--providers.docker.exposedbydefault=false",
                "--entrypoints.web.address=:80"
            ],
            "Image": "traefik:v2.0.0-rc3",
            "Volumes": {
                "/tmp": {},
                "/var/run/docker.sock": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "/traefik"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "33c2e85f5b943058f0a159da8371e001fdce6bec03409153d50639f3a5a22450",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "traefik2",
                "com.docker.compose.service": "traefik",
                "com.docker.compose.version": "1.21.0",
                "org.opencontainers.image.description": "A modern reverse-proxy",
                "org.opencontainers.image.documentation": "https://docs.traefik.io",
                "org.opencontainers.image.title": "Traefik",
                "org.opencontainers.image.url": "https://traefik.io",
                "org.opencontainers.image.vendor": "Containous",
                "org.opencontainers.image.version": "v2.0.0-rc3"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "d4afe7243c40a6bb4730a4a97e5b7de6f8d2383b33c58488514b29fd558d2128",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/d4afe7243c40",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "traefik2_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "23f1c5460c0c",
                        "traefik"
                    ],
                    "NetworkID": "97a1d07f7d1d61f8eec067a7a3c5eb59292eb79c131d4fe10e5e75ffd8bacf5f",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }
        }
    }
]

My understanding is that the curl command is trying to reach your docker engine through the proxy.
The corporate proxy then, forwards the request to Traefik, as you can see in the logs.

But by forwarding the request, your corporate proxy rewrites the Host header and put the initial value in the X-Forwarded-Host, which create a mess of the request.

Is it possible to reach traefik from your machine without going through the corporate proxy? If yes, then append the domain to your NO_PROXY environment variable, so curl will hit Traefik directly.

If not, you'll have to provide a network diagram including your machine, the docker engine and the proxy.

I did some more test with the container. As far as I can see (tcpdump captures) the "Config": { "Env" : [ "HTTP_PROXY= ... part is the problem.

What happens is the request from the client reaches the docker host, gets forwarded to the traefik container and the container sends the request not via the internal docker network to the whoami container but via the proxy set in the Env Config out.

I found the following issue on GitHub regarding this problem https://github.com/containous/traefik/issues/3509

The issue is closed so I assumed it was fixed not only in 1.x but also 2.x

Some more digging showed me a currently working solution.

$ cat ~/.docker/config.json
{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://proxy.internaldns.com:80",
     "httpsProxy": "http://proxy.internaldns.com:80",
     "noProxy": "localhost,127.0.0.1,::1,172.0.0.0/8"
   }
 }
}

This results in the following Config Env part in docker inspect

            "Env": [
                "HTTP_PROXY=http://proxy.internaldns.com:80",
                "http_proxy=http://proxy.internaldns.com:80",
                "HTTPS_PROXY=http://proxy.internaldns.com:80",
                "https_proxy=http://proxy.internaldns.com:80",
                "NO_PROXY=localhost,172.0.0.0/8",
                "no_proxy=localhost,172.0.0.0/8",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],

The "noProxy": "localhost,172.0.0.0/8" did the trick. Now request get forwarded from traefik via the docker internal network.

Thanks for your input.

1 Like