Deprecated. See Starting traefik
.
docker-traefik.yml
version: '3'
services:
traefik:
image: traefik:1.7
# remove command comments
command: --docker # enable Docker Provider
--docker.swarmmode # use Docker Swarm Mode as data provider
--api # debugging (enable UI)
--logLevel=DEBUG # debugging
--traefikLog.filePath=/traefik.log # debugging
--accessLog.filePath=/access.log # debugging
ports:
- "80:80"
- "8080:8080" # debugging (expose UI's port)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # for it to be able to listen to Docker events
- ./traefik.log:/traefik.log # debugging
- ./access.log:/access.log # debugging
docker-whoami.yml
:
version: '3'
networks:
traefik_default:
external: true
services:
whoami:
image: containous/whoami
networks:
- traefik_default # add to traefik network
deploy:
labels:
- "traefik.port=80" # whoami is on port 80
- "traefik.docker.network=traefik_default" # whoami is on traefik_default network
- "traefik.frontend.rule=Host:example.com" # when to forward requests to whoami
$ touch traefik.log access.log
$ docker stack deploy -c docker-traefik.yml traefik
$ docker stack deploy -c docker-whoami.yml whoami
$ curl -sSL example.com
Hostname: bf9c2d10bebf
IP: 127.0.0.1
IP: 10.0.63.6
IP: 172.21.0.4
GET / HTTP/1.1
Host: example.com
User-Agent: curl/7.65.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 10.255.0.2
X-Forwarded-Host: example.com
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Server: 2405167c3d7f
X-Real-Ip: 10.255.0.2
traefik.log
:
time="2019-06-22T06:30:33Z" level=info msg="Traefik version v1.7.12 built on 2019-05-29_07:35:02PM"
time="2019-06-22T06:30:33Z" level=debug msg="Global configuration loaded {
"LifeCycle":{
"RequestAcceptGraceTimeout":0,
"GraceTimeOut":10000000000
},
"GraceTimeOut":0,
"Debug":false,
"CheckNewVersion":true,
"SendAnonymousUsage":false,
"AccessLogsFile":"",
"AccessLog":{
"file":"/access.log",
"format":"common"
},
"TraefikLogsFile":"",
"TraefikLog":{
"file":"/traefik.log",
"format":"common"
},
"Tracing":null,
"LogLevel":"DEBUG",
"EntryPoints":{
"http":{
"Address":":80",
"TLS":null,
"Redirect":null,
"Auth":null,
"WhitelistSourceRange":null,
"WhiteList":null,
"Compress":false,
"ProxyProtocol":null,
"ForwardedHeaders":{
"Insecure":true,
"TrustedIPs":null
}
},
"traefik":{
"Address":":8080",
"TLS":null,
"Redirect":null,
"Auth":null,
"WhitelistSourceRange":null,
"WhiteList":null,
"Compress":false,
"ProxyProtocol":null,
"ForwardedHeaders":{
"Insecure":true,
"TrustedIPs":null
}
}
},
"Cluster":null,
"Constraints":[],
"ACME":null,
"DefaultEntryPoints":["http"],
"ProvidersThrottleDuration":2000000000,
"MaxIdleConnsPerHost":200,
"IdleTimeout":0,
"InsecureSkipVerify":false,
"RootCAs":null,
"Retry":null,
"HealthCheck":{
"Interval":30000000000
},
"RespondingTimeouts":null,
"ForwardingTimeouts":null,
"AllowMinWeightZero":false,
"KeepTrailingSlash":false,
"Web":null,
"Docker":{
"Watch":true,
"Filename":"",
"Constraints":null,
"Trace":false,
"TemplateVersion":2,
"DebugLogGeneratedTemplate":false,
"Endpoint":"unix:///var/run/docker.sock",
"Domain":"",
"TLS":null,
"ExposedByDefault":true,
"UseBindPortIP":false,
"SwarmMode":true,
"Network":"",
"SwarmModeRefreshSeconds":15
},
"File":null,
"Marathon":null,
"Consul":null,
"ConsulCatalog":null,
"Etcd":null,
"Zookeeper":null,
"Boltdb":null,
"Kubernetes":null,
"Mesos":null,
"Eureka":null,
"ECS":null,
"Rancher":null,
"DynamoDB":null,
"ServiceFabric":null,
"Rest":null,
"API":{
"EntryPoint":"traefik",
"Dashboard":true,
"Debug":false,
"CurrentConfigurations":null,
"Statistics":null
},
"Metrics":null,
"Ping":null,
"HostResolver":null
}"
time="2019-06-22T06:30:33Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/basics/#collected-data\n"
time="2019-06-22T06:30:33Z" level=info msg="Preparing server http &{Address::80 TLS:<nil> Redirect:<nil> Auth:<nil> WhitelistSourceRange:[] WhiteList:<nil> Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc00036ebc0} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s"
time="2019-06-22T06:30:33Z" level=info msg="Preparing server traefik &{Address::8080 TLS:<nil> Redirect:<nil> Auth:<nil> WhitelistSourceRange:[] WhiteList:<nil> Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc00036ebe0} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s"
time="2019-06-22T06:30:33Z" level=info msg="Starting server on :80"
time="2019-06-22T06:30:33Z" level=info msg="Starting provider configuration.ProviderAggregator {}"
time="2019-06-22T06:30:33Z" level=info msg="Starting server on :8080"
time="2019-06-22T06:30:33Z" level=info msg="Starting provider *docker.Provider {
"Watch":true,
"Filename":"",
"Constraints":null,
"Trace":false,
"TemplateVersion":2,
"DebugLogGeneratedTemplate":false,
"Endpoint":"unix:///var/run/docker.sock",
"Domain":"",
"TLS":null,
"ExposedByDefault":true,
"UseBindPortIP":false,
"SwarmMode":true,
"Network":"",
"SwarmModeRefreshSeconds":15
}"
time="2019-06-22T06:30:33Z" level=debug msg="Provider connection established with docker 18.09.6-ce (API 1.39)"
time="2019-06-22T06:30:33Z" level=debug msg="originLabelsmap[
traefik.frontend.rule:Host:example.com
traefik.port:80
com.docker.stack.image:containous/whoami
com.docker.stack.namespace:whoami
traefik.docker.network:traefik_default
]"
time="2019-06-22T06:30:33Z" level=debug msg="allLabelsmap[:map[
traefik.docker.network:traefik_default
traefik.frontend.rule:Host:example.com
traefik.port:80
]]"
time="2019-06-22T06:30:33Z" level=debug msg="originLabelsmap[
com.docker.stack.image:containous/whoami
com.docker.stack.namespace:whoami
traefik.docker.network:traefik_default
traefik.frontend.rule:Host:example.com
traefik.port:80
]"
time="2019-06-22T06:30:33Z" level=debug msg="allLabelsmap[:map[
traefik.docker.network:traefik_default
traefik.frontend.rule:Host:example.com
traefik.port:80
]]"
time="2019-06-22T06:30:33Z" level=debug msg="Backend backend-whoami-whoami: no load-balancer defined, fallback to 'wrr' method"
time="2019-06-22T06:30:33Z" level=debug msg="Configuration received from provider docker: {
"backends":{
"backend-whoami-whoami":{
"servers":{
"server-whoami-whoami-1-7238207aec47f3e74e4f0b7851177df8":{
"url":"http://10.0.59.15:80",
"weight":1
}
},
"loadBalancer":{"method":"wrr"}
}
},
"frontends":{
"frontend-Host-example.com-0":{
"entryPoints":["http"],
"backend":"backend-whoami-whoami",
"routes":{
"route-frontend-Host-example.com-0":{"rule":"Host:example.com"}
},
"passHostHeader":true,
"priority":0,
"basicAuth":null
}
}
}"
time="2019-06-22T06:30:33Z" level=debug msg="Wiring frontend frontend-Host-example.com-0 to entryPoint http"
time="2019-06-22T06:30:33Z" level=debug msg="Creating backend backend-whoami-whoami"
time="2019-06-22T06:30:33Z" level=debug msg="Adding TLSClientHeaders middleware for frontend frontend-Host-example.com-0"
time="2019-06-22T06:30:33Z" level=debug msg="Creating load-balancer wrr"
time="2019-06-22T06:30:33Z" level=debug msg="Creating server server-whoami-whoami-1-7238207aec47f3e74e4f0b7851177df8 at http://10.0.59.15:80 with weight 1"
time="2019-06-22T06:30:33Z" level=debug msg="Creating route route-frontend-Host-example.com-0 Host:example.com"
time="2019-06-22T06:30:33Z" level=info msg="Server configuration reloaded on :80"
time="2019-06-22T06:30:33Z" level=info msg="Server configuration reloaded on :8080"
time="2019-06-22T07:07:57Z" 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.0"]
},
"ContentLength":0,
"TransferEncoding":null,
"Host":"example.com",
"Form":null,
"PostForm":null,
"MultipartForm":null,
"Trailer":null,
"RemoteAddr":"10.255.0.2:33204",
"RequestURI":"/",
"TLS":null
}"
time="2019-06-22T07:07:57Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" ForwardURL="http://10.0.59.15:80" Request="{...}"
time="2019-06-22T07:07:57Z" level=debug msg="vulcand/oxy/forward: begin ServeHttp on request" Request="{
...
"URL":{
"Scheme":"http",
...
"Host":"10.0.59.15:80",
"Path":"",
...
},
...
}"
time="2019-06-22T07:07:57Z" level=debug msg="vulcand/oxy/forward/http: begin ServeHttp on request" Request="{
...
"URL":{
"Scheme":"http",
...
"Host":"10.0.59.15:80",
"Path":"",
...
},
...
}"
time="2019-06-22T07:07:57Z" level=debug msg="Upstream ResponseWriter of type *pipelining.writerWithoutCloseNotify does not implement http.CloseNotifier. Returning dummy channel."
time="2019-06-22T07:07:57Z" level=debug msg="vulcand/oxy/forward/http: Round trip: http://10.0.59.15:80, code: 200, Length: 321, duration: 1.193001ms"
time="2019-06-22T07:07:57Z" level=debug msg="vulcand/oxy/forward/http: completed ServeHttp on request" Request="{
...
"URL":{
"Scheme":"http",
...
"Host":"10.0.59.15:80",
"Path":"",
...
},
...
}"
time="2019-06-22T07:07:57Z" level=debug msg="vulcand/oxy/forward: completed ServeHttp on request" Request="{
...
"URL":{
"Scheme":"http",
...
"Host":"10.0.59.15:80",
"Path":"",
...
},
...
}"
time="2019-06-22T07:07:57Z" level=debug msg="vulcand/oxy/roundrobin/rr: completed ServeHttp on request" Request="{...}"