Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two frontend rules, two backend ports, using segments, round robin uses both ports #3744

Closed
r3kzi opened this issue Aug 8, 2018 · 2 comments

Comments

@r3kzi
Copy link

r3kzi commented Aug 8, 2018

Do you want to request a feature or report a bug?

Bug

What did you do?

My setup consists of 2 docker container:

  • springboot application
  • traefik

I spinned them up witch a docker-compose file:

version: "3"
services:
  springboot-application:
    image: springboot-application:latest
    hostname: springboot-application
    container_name: springboot-application
    labels:
      traefik.application.frontend.rule: "Host: springboot-application.net"
      traefik.actuator.frontend.rule: "PathPrefix: /_/springboot-application/actuator/; ReplacePathRegex: ^/_/springboot-application/ /$$1"
      traefik.application.port: "8080"
      traefik.actuator.port: "8081"
      traefik.backend: "springboot-application"
      traefik.frontend.entryPoints: "http"
      traefik.docker.network: "traefik"
  traefik:
    image: traefik
    hostname: traefik
    container_name: traefik
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - $PWD/traefik/traefik.toml:/etc/traefik/traefik.toml
    ports:
    - "8500:8500"
    - "8080:8080"

I used curl twice one after another to test frontend rules.

$ curl --header 'Host: springboot-application.net' 'http://localhost:8500'
$ curl --header 'Host: springboot-application.net' 'http://localhost:8500'

Log output for the first curl:

time="2018-08-08T09:21:10Z" level=debug msg="vulcand/oxy/forward/http: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.22.0.3:8080\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.22.0.1:48996\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:21:10Z" level=debug msg="Upstream ResponseWriter of type *pipelining.writerWithoutCloseNotify does not implement http.CloseNotifier. Returning dummy channel."
time="2018-08-08T09:21:10Z" level=debug msg="vulcand/oxy/forward/http: Round trip: http://172.22.0.3:8080, code: 200, Length: 1499, duration: 188.052881ms"

See Round trip:

Round trip: http://172.22.0.3:8080, code: 200, Length: 1499, duration: 188.052881ms"

Log output for the second curl:

time="2018-08-08T09:21:11Z" level=debug msg="vulcand/oxy/forward/http: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.22.0.3:8081\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.22.0.1:49002\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:21:11Z" level=debug msg="Upstream ResponseWriter of type *pipelining.writerWithoutCloseNotify does not implement http.CloseNotifier. Returning dummy channel."
time="2018-08-08T09:21:11Z" level=debug msg="vulcand/oxy/forward/http: Round trip: http://172.22.0.3:8081, code: 404, Length: 121, duration: 6.542466ms"

See Round trip:

Round trip: http://172.22.0.3:8081, code: 404, Length: 121, duration: 6.542466ms"

What did you expect to see?

$ curl --header 'Host: springboot-application.net' 'http://localhost:8500'

is only using backend port 8080!

And..

$ curl 'http://localhost:8500/_/springboot-application/actuator/'

is only using backend port 8081!

What did you see instead?

It looks like even when traefik.actuator.frontend.rule didn't match traefik uses both defined
backend port for Round Robin.

Output of traefik version: (What version of Traefik are you using?)

$ docker exec -it traefik /traefik version                                                                                              Mi 08 Aug 2018 11:34:50 CEST
Version:      v1.6.5
Codename:     tetedemoine
Go version:   go1.10.3
Built:        2018-07-10_03:54:03PM
OS/Arch:      linux/amd64

What is your environment & configuration (arguments, toml, provider, platform, ...)?

logLevel = "DEBUG"

################################################################
# API and dashboard configuration
################################################################
[api]
################################################################
# Docker configuration backend
################################################################
[docker]
domain = "docker.local"
watch = true

# Entrypoints definition
#
# Optional
# Default:
[entryPoints]
    [entryPoints.http]
    address = ":8500"

# Enable access logs
# By default it will write to stdout and produce logs in the textual
# Common Log Format (CLF), extended with additional fields.
#
# Optional
#
[accessLog]

Complete log output:

time="2018-08-08T09:37:05Z" 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.58.0\"]
},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48014\",\"RequestUR
I\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:05Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" ForwardURL="http://172.23.0.2:8080" 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.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48014\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:05Z" level=debug msg="vulcand/oxy/forward: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.23.0.2:8080\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48014\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:05Z" level=debug msg="vulcand/oxy/forward/http: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.23.0.2:8080\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48014\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:05Z" level=debug msg="Upstream ResponseWriter of type *pipelining.writerWithoutCloseNotify does not implement http.CloseNotifier. Returning dummy channel."
time="2018-08-08T09:37:06Z" level=debug msg="vulcand/oxy/forward/http: Round trip: http://172.23.0.2:8080, code: 200, Length: 1499, duration: 336.016253ms"
time="2018-08-08T09:37:06Z" level=debug msg="vulcand/oxy/forward/http: completed ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.23.0.2:8080\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48014\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:06Z" level=debug msg="vulcand/oxy/forward: completed ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.23.0.2:8080\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48014\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:06Z" level=debug msg="vulcand/oxy/roundrobin/rr: completed 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.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48014\",\"RequestURI\":\"/\",\"TLS\":null}"
172.23.0.1 - - [08/Aug/2018:09:37:05 +0000] "GET / HTTP/1.1" 200 1499 "-" "curl/7.58.0" 1 "actuator-springboot-application-stack-springboot-application" "http://172.23.0.2:8080" 336ms
time="2018-08-08T09:37:07Z" 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.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48022\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:07Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" ForwardURL="http://172.23.0.2:8081" 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.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48022\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:07Z" level=debug msg="vulcand/oxy/forward: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.23.0.2:8081\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48022\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:07Z" level=debug msg="vulcand/oxy/forward/http: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.23.0.2:8081\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48022\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:07Z" level=debug msg="Upstream ResponseWriter of type *pipelining.writerWithoutCloseNotify does not implement http.CloseNotifier. Returning dummy channel."
time="2018-08-08T09:37:07Z" level=debug msg="vulcand/oxy/forward/http: Round trip: http://172.23.0.2:8081, code: 404, Length: 121, duration: 64.187531ms"
time="2018-08-08T09:37:07Z" level=debug msg="vulcand/oxy/forward/http: completed ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.23.0.2:8081\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48022\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:07Z" level=debug msg="vulcand/oxy/forward: completed ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"172.23.0.2:8081\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/1.1\",\"ProtoMajor\":1,\"ProtoMinor\":1,\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48022\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2018-08-08T09:37:07Z" level=debug msg="vulcand/oxy/roundrobin/rr: completed 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.58.0\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"springboot-application.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:48022\",\"RequestURI\":\"/\",\"TLS\":null}"
172.23.0.1 - - [08/Aug/2018:09:37:07 +0000] "GET / HTTP/1.1" 404 121 "-" "curl/7.58.0" 2 "actuator-springboot-application-stack-springboot-application" "http://172.23.0.2:8081" 64ms
@ldez
Copy link
Member

ldez commented Aug 8, 2018

Could you removed traefik.backend: "springboot-application"

@ldez
Copy link
Member

ldez commented Aug 8, 2018

Duplicate of #2752, #3351
Related to #3317

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants