Traefik Forward Authentication not working

0 votes

I'm trying to adapt the tutorial available here with the authentication config detailed on official Trafik documentation.

I created a simple service that always respond with 200 OK when receive a GET request on this address: http://172.27.10.56:9999/verify

Then, I changed my traefik.toml, and included this:

[entrypoints.http.auth.forward]
address = "http://172.27.10.56:9999/verify"

But my authentication service is never called. In fact, with this config, the traefik stop to redirect all requests.

Here is my Dockerfile:

FROM traefik:v1.4.1-alpine
ADD traefik.toml /traefik.toml

Here is my traefik.toml

debug = true
logLevel = "DEBUG"
defaultEntryPoints = ["http"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entrypoints.http.auth.forward]
    address = "http://172.27.10.56:9999/verify"

[web]
address = ":8080"

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "docker.localhost"
watch = true

and Here is my docker-compose.yaml

traefik:
  image: dsp/traefik
  ports:
    - "80:80"
    - "8080:8080"
    - "443:443"
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock

machine:
  image: katacoda/docker-http-server
  labels:
    - "traefik.backend=machine-echo"
    - "traefik.frontend.rule=Host:machine-echo.example.com"

echo:
  image: katacoda/docker-http-server:v2
  labels:
    - "traefik.backend=echo"
    - "traefik.frontend.rule=Host:echo-echo.example.com"

and here is the output of traefik startup:

time="2017-10-26T15:00:17Z" level=info msg="Using TOML configuration file //traefik.toml" 
time="2017-10-26T15:00:17Z" level=info msg="Traefik version v1.4.1 built on 2017-10-24_05:25:28PM" 
time="2017-10-26T15:00:17Z" level=debug msg="Global configuration loaded {"GraceTimeOut":10000000000,"Debug":true,"CheckNewVersion":true,"AccessLogsFile":"","AccessLog":null,"TraefikLogsFile":"","LogLevel":"DEBUG","EntryPoints":{"http":{"Network":"","Address":"","TLS":null,"Redirect":null,"Auth":{"Basic":null,"Digest":null,"Forward":{"Address":"http://172.27.10.56:9999/verify","TLS":null,"TrustForwardHeader":false},"HeaderField":""},"WhitelistSourceRange":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,"Docker":{"Watch":true,"Filename":"","Constraints":null,"Trace":false,"DebugLogGeneratedTemplate":false,"Endpoint":"unix:///var/run/docker.sock","Domain":"docker.localhost","TLS":null,"ExposedByDefault":true,"UseBindPortIP":false,"SwarmMode":false},"File":null,"Web":{"Address":":8080","CertFile":"","KeyFile":"","ReadOnly":false,"Statistics":null,"Metrics":null,"Path":"/","Auth":null,"Debug":false,"CurrentConfigurations":null,"Stats":null,"StatsRecorder":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}" 
time="2017-10-26T15:00:17Z" level=info msg="Preparing server http &{Network: Address: TLS:<nil> Redirect:<nil> Auth:0xc4204da780 WhitelistSourceRange:[] Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc4202a07c0} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s" 
time="2017-10-26T15:00:17Z" level=info msg="Starting provider *docker.Provider {"Watch":true,"Filename":"","Constraints":null,"Trace":false,"DebugLogGeneratedTemplate":false,"Endpoint":"unix:///var/run/docker.sock","Domain":"docker.localhost","TLS":null,"ExposedByDefault":true,"UseBindPortIP":false,"SwarmMode":false}" 
time="2017-10-26T15:00:17Z" level=info msg="Starting server on " 
time="2017-10-26T15:00:17Z" level=info msg="Starting provider *web.Provider {"Address":":8080","CertFile":"","KeyFile":"","ReadOnly":false,"Statistics":null,"Metrics":null,"Path":"/","Auth":null,"Debug":true,"CurrentConfigurations":{},"Stats":{"Uptime":"2017-10-26T15:00:17.777369487Z","Pid":1,"ResponseCounts":{},"TotalResponseCounts":{},"TotalResponseTime":"0001-01-01T00:00:00Z"},"StatsRecorder":null}" 
time="2017-10-26T15:00:17Z" level=debug msg="Provider connection established with docker 17.10.0-ce-rc1 (API 1.33)" 
time="2017-10-26T15:00:17Z" level=debug msg="Validation of load balancer method for backend backend-echo failed: invalid load-balancing method ''. Using default method wrr." 
time="2017-10-26T15:00:17Z" level=debug msg="Validation of load balancer method for backend backend-machine-echo failed: invalid load-balancing method ''. Using default method wrr." 
time="2017-10-26T15:00:17Z" level=debug msg="Validation of load balancer method for backend backend-traefik-traefik failed: invalid load-balancing method ''. Using default method wrr." 
time="2017-10-26T15:00:17Z" level=debug msg="Configuration received from provider docker: {"backends":{"backend-echo":{"servers":{"server-traefik_echo_1":{"url":"http://172.17.0.2:80","weight":0}},"loadBalancer":{"method":"wrr"}},"backend-machine-echo":{"servers":{"server-traefik_machine_1":{"url":"http://172.17.0.3:80","weight":0}},"loadBalancer":{"method":"wrr"}},"backend-traefik-traefik":{"servers":{"server-traefik_traefik_1":{"url":"http://172.17.0.4:80","weight":0}},"loadBalancer":{"method":"wrr"}}},"frontends":{"frontend-Host-echo-echo-example-com":{"entryPoints":["http"],"backend":"backend-echo","routes":{"route-frontend-Host-echo-echo-example-com":{"rule":"Host:echo-echo.example.com"}},"passHostHeader":true,"priority":0,"basicAuth":[],"headers":{}},"frontend-Host-machine-echo-example-com":{"entryPoints":["http"],"backend":"backend-machine-echo","routes":{"route-frontend-Host-machine-echo-example-com":{"rule":"Host:machine-echo.example.com"}},"passHostHeader":true,"priority":0,"basicAuth":[],"headers":{}},"frontend-Host-traefik-traefik-docker-localhost":{"entryPoints":["http"],"backend":"backend-traefik-traefik","routes":{"route-frontend-Host-traefik-traefik-docker-localhost":{"rule":"Host:traefik.traefik.docker.localhost"}},"passHostHeader":true,"priority":0,"basicAuth":[],"headers":{}}}}" 
time="2017-10-26T15:00:17Z" level=debug msg="Last docker config received more than 2s, OK" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating frontend frontend-Host-echo-echo-example-com" 
time="2017-10-26T15:00:17Z" level=debug msg="Wiring frontend frontend-Host-echo-echo-example-com to entryPoint http" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating route route-frontend-Host-echo-echo-example-com Host:echo-echo.example.com" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating backend backend-echo" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating load-balancer wrr" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating server server-traefik_echo_1 at http://172.17.0.2:80 with weight 0" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating frontend frontend-Host-machine-echo-example-com" 
time="2017-10-26T15:00:17Z" level=debug msg="Wiring frontend frontend-Host-machine-echo-example-com to entryPoint http" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating route route-frontend-Host-machine-echo-example-com Host:machine-echo.example.com" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating backend backend-machine-echo" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating load-balancer wrr" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating server server-traefik_machine_1 at http://172.17.0.3:80 with weight 0" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating frontend frontend-Host-traefik-traefik-docker-localhost" 
time="2017-10-26T15:00:17Z" level=debug msg="Wiring frontend frontend-Host-traefik-traefik-docker-localhost to entryPoint http" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating route route-frontend-Host-traefik-traefik-docker-localhost Host:traefik.traefik.docker.localhost" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating backend backend-traefik-traefik" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating load-balancer wrr" 
time="2017-10-26T15:00:17Z" level=debug msg="Creating server server-traefik_traefik_1 at http://172.17.0.4:80 with weight 0" 
time="2017-10-26T15:00:17Z" level=info msg="Server configuration reloaded on " 

When I test the Traefik, here is the output:

curl -H Host:machine-echo.example.com http://127.0.0.1
curl: (56) Recv failure: Connection reset by peer

But, when I removed the forward authentication config from traefik.toml, the request was successfully redirected to the docker container:

curl -H Host:machine-echo.example.com http://127.0.0.1
<h1>This request was processed by host: 2a291e3bb05f</h1>

whats going wrong here?

Aug 27, 2018 in Kubernetes by lina
• 8,220 points
3,863 views

1 answer to this question.

0 votes

Look at the 7th line of your traefik.toml

you've written 

[entrypoints.http.auth.forward]

It should be 

[entryPoints.http.auth.forward]
answered Aug 27, 2018 by Kalgi
• 52,360 points

Related Questions In Kubernetes

+1 vote
1 answer

--image-pull-policy not working in kubernetes

Kubernetes does not automatically update the pods ...READ MORE

answered Dec 6, 2018 in Kubernetes by DareDev
• 6,890 points
4,963 views
0 votes
1 answer

External IP not working with Minikube Kubernetes

You can use an ingress controller on ...READ MORE

answered Jan 24, 2019 in Kubernetes by DareDev
• 6,890 points
2,326 views
0 votes
4 answers

minikube start is giving OS Type not recognized

I had the same issue. i had ...READ MORE

answered Apr 30, 2019 in Kubernetes by Lisa
2,430 views
0 votes
1 answer

Pod not sharing directory - Kubernetes volume Hostpath

he issue was on the volume definition, ...READ MORE

answered Aug 28, 2018 in Kubernetes by Kalgi
• 52,360 points
2,032 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
14,580 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 6,060 views
0 votes
2 answers

Kubernetes(GKE) cronjob not working

Adding to @Kalgi's answer I think you ...READ MORE

answered Sep 19, 2018 in Kubernetes by Nilesh
• 7,050 points
2,291 views
0 votes
2 answers

kubernetes: AWS ELB not working

Set your service to loadbalancer apiVersion: v1 kind: Service metadata: ...READ MORE

answered Oct 9, 2018 in Kubernetes by Nilesh
• 7,050 points
755 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP