Serving both Ping + API/Dashboard securely, but ping without requiring authentication

In v1, one could setup Traefik to expose it's dashboard, api and ping, but the ping endpoint would not be subject to authentication.

In v2, I am unable to attach two services to the same router (api@internal, ping@internal) - and the middleware defined for authentication applies to the entire router; so even if I would get both services working on the same router, both would also be subject to authentication.

In v1 this was as simple as setting:

  --entrypoints=Name: <http and https> ...
  --entrypoints=Name:traefik Address::8080 Auth.Basic.Users:...
  - traefik.port=8080
  - -> required auth -> did not require auth

How can I achieve the same in Traefik v2?

My solution in v2 at the moment:

      - "traefik.enable=true"
      # Dashboard
      - "traefik.http.routers.traefik-secure.rule=Host(``)"
      - "traefik.http.routers.traefik-secure.tls=true"
      - "traefik.http.routers.traefik-secure.tls.certresolver=http"
      - "traefik.http.routers.traefik-secure.service=api@internal"

      # Dashboard Authentication 
      - "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
      - "traefik.http.middlewares.traefik-auth.basicauth.users=user:..."

      # Secure Ping endpoint
      - "``) && Path(`/ping`)"
      - ""
      - ""
      - ""

Is this the preferred/correct approach?

Hello, it's the correct approach.

Just a question: why do you want to expose your ping over internet?

Hi Idez,

To be able to perform ping probes from several different regions (For instance PingDom). This way I can determine amongst others availability of my web application from Asia and the USA.