Traefik V2 with multiple non docker backend

Hi all,
I followed the excellent article by Moritz to go to version 2 of Traefik. But I would like to add several backends which are not on Docker and I completely block ...

http:
  routers:
    my-api:
      entryPoints:
      # Expose on :8080 aka 'dashboard'
        - dashboard
      # Activate this Router if Client asks for '/dashboard' or '/api'
      rule: "PathPrefix(`/dashboard`) || PathPrefix(`/api`)"
      # Expose the API
      service: api@internal
      # Use basic auth Middleware define below 
      middlewares:
        - dashboard-auth

    my-secure-api:
      entryPoints:
      # Expose via https
        - https
      # Activate this Router if Client requests specific subdomain and '/dashboard' or '/api'
      rule: "Host(`dashboard.traefik.moritzvd.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
      service: api@internal
      middlewares:
        - dashboard-auth
      tls:
        # Use ACME HTTP Challgen defined in 'traefik.yml' to get valid cert
        certResolver: myhttpchallenge

    # Catch all global Router for redirects
    https-redirect:
      entryPoints:
        - http
      # Activate this Router on any Host requested
      rule: "hostregexp(`{host:.+}`)"
      # A service definition is mandatory that's why we use a dummy service define at the bottom
      service: dummy
      middlewares:
        - redirect-to-https

  middlewares:
    dashboard-auth:
      basicAuth:
        users:
          # admin:passw0rd
          - "admin:$2y$05$kqK7GlhnGCnt/fYdrCL2AeZykK2T0cN4sBcCaRs61vMz7yMWaR9M."
      
    redirect-to-https:
      redirectScheme:
        scheme: https
        permanent: true

  services:
    dummy:
      loadBalancer:
        servers:
          - url: localhost

Hello @houstek,

Can you please elaborate as to what you are trying to accomplish?

If you are just looking to add more routers and services, you can follow the configuration examples (https://docs.traefik.io/v2.1/providers/file/#configuration-examples) to add more to your config.

1 Like

With a configuration identical to this one: https://moritzvd.com/upgrade-traefik-2/
I would like to access a web server on my local network (http://192.168.10.10) which is not on Docker and redirect HTTP to HTTPS

the problem in your example is that it uses api@internal which doesn't need any service declaration.
your web server need one.
something like:

services:
    web_external:
      loadBalancer:
        servers:
          - url: http://192.168.10.10:80

and you can have the router like this:

routers:
    web_external:
      entryPoints:
        - https
      service: web_external