Skip to content

Some frontend configuration is ignored when re-using same backend #2323

@jeffreykoetsier

Description

@jeffreykoetsier

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

Bug

What did you do?

When two frontends are using the same backend, only the first processed frontend is able to set settings like basicAuth or whitelistSourceRange.

I would like to use multiple frontends to apply different behaviour based on the Path of the URI.

A simple test scenario:
Two frontends with a different PathPrefix but using the same backend

frontend website-a:

  • priority: 10
  • backend: app
  • rule: "PathPrefix: /secure"
  • basicAuth: ["aaa:aaa"]

frontend website-b:

  • priority: 5
  • backend: app
  • rule: "PathPrefix: /hello"

backend app:

A short investigation in Traefik's code reveals the following:

server/server.go:

    if backends[entryPointName+frontend.Backend] == nil {
      ...
      Configure IP Whitelist
      Configure Basic Auth
      etc.. etc..
      ...
    } else {
      log.Debugf("Reusing backend %s", frontend.Backend)
    }

It seems frontend specific settings are skipped because the backend is already configured.

When I duplicate the backend configuration to app2 and configure app2 as a backend on website-b the configuration works as expected.

What did you expect to see?

In case of basic authentication defined on two frontends using the same backend:

$ http localhost/secure
HTTP/1.1 401 Unauthorized
$ http localhost/hello
HTTP/1.1 200 OK

What did you see instead?

In case of basic authentication defined on two frontends using the same backend:

$ http localhost/secure
HTTP/1.1 401 Unauthorized
$ http localhost/hello
HTTP/1.1 401 Unauthorized

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

Traefik 1.4.0

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

    [file]
    [frontends]
      [frontends.website-a]
      priority = 10
      backend = "app"
      basicAuth = ["aaa:aaa"]
    
        [frontends.website-a.routes.a]
          rule = "PathPrefix: /secure"

      [frontends.website-b]
      priority = 5
      backend = "app"
    
      [frontends.website-b.routes.b]
        rule = "PathPrefix: /hello"
    
    [backends]
      [backends.app]
        [backends.app.servers.app]
        url = "http://10.10.10.10:32779/"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions