Route to service with path

How would I configure a router and service such that adminer.example.com routes to postgresql:80/adminer

So far I've got:

http:
  routers:
    adminer:
      rule: "Host(`adminer.dhnode.com`)"
      service: "adminer"
      entryPoints:
        - "websecure"
  services:
    adminer:
      loadBalancer:
        servers:
          - url: "http://postgresql:80/adminer/"

But this just routes to postgresql:80

Thanks

The target URL just uses the domain and port, in http protocol and proxy the path is handled differently.

You can probably add the path with addprefix middleware (doc).

But be aware that GUI web apps mostly don’t like to have their path manipulated, as their first response web page usually includes absolute paths for further dependencies. Those will break when changing path via middleware.

You could create an extra router for domain and Path(/) and redirect to path /adminer. That way you only need to enter the domain.

Thanks for that. Got it working with addPrefix and rewrite-cookie-path

experimental:
  plugins:
    rewrite-cookie-path:
      moduleName: "github.com/vnghia/traefik-plugin-rewrite-cookie-path"
      version: "v0.0.1"

http:
  routers:
    adminer:
      rule: "Host(`adminer.example.com`)
      service: "adminer"
      entryPoints:
        - "websecure"
      middlewares:
        - "add-adminer"
        - "rewrite-cookie-path"
  services:
    adminer:
      loadBalancer:
        servers:
          - url: "http://postgresql:80"
  middlewares:
    add-adminer:
      addPrefix:
        prefix: "/adminer"
    rewrite-cookie-path:
      plugin:
        rewrite-cookie-path:
          rewrites:
            - name: adminer_sid
              regex: "adminer/"
              replacement: ""
            - name: adminer_permanent
              regex: "adminer/"
              replacement: ""
            - name: adminer_key
              regex: "adminer/"
              replacement: ""

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.