Problems with Portainer, pgAdmin4 and URL Path: stripprefix, redirectregex, etc

  • Traefik v2.2

I would like help to get on Traefik what I have on nginx.
Both Portainer and pgadmin4 work using path in the url.

On nginx.conf:

    location /pgadmin4/ {
      proxy_set_header X-Script-Name /pgadmin4;
      proxy_set_header Host $host;
      proxy_pass http://pgadmin4/;
      proxy_redirect off;
    }

    location /portainer/ {
      proxy_http_version 1.1;
      proxy_set_header Host $http_host;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_cache_bypass $http_upgrade;
      proxy_pass_request_headers on;
      proxy_pass http://portainer:9000/;
    }

On docker-compose i try this:

(Pgadmin4)

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.pgadmin4.rule=PathPrefix(`/pgadmin4`)"
      - "traefik.http.routers.pgadmin4.middlewares=pgadmin4PStrip"
      - "traefik.http.middlewares.pgadmin4PStrip.stripprefix.prefixes=/pgadmin4"

(Portainer)

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.portainer.rule=PathPrefix(`/portainer`)"
      - "traefik.http.routers.portainer.middlewares=portainerPStrip"
      - "traefik.http.middlewares.portainerPStrip.stripprefix.prefixes=/portainer"

Any help will be appreciated!

After several days, a solution for Portainer.


labels:
      - "traefik.enable=true"
      - "traefik.http.routers.portainer.rule=PathPrefix(`/portainer`)"
      - "traefik.http.routers.portainer.middlewares=portainerRedir,portainerPStrip"
      - "traefik.http.middlewares.portainerPStrip.stripprefix.prefixes=/portainer"
      - "traefik.http.middlewares.portainerRedir.redirectregex.regex=^(.*)/portainer$$"
      - "traefik.http.middlewares.portainerRedir.redirectregex.replacement=$${1}/portainer/"

The problem with pgAdmin4 still persists!

pgAdmin4 Solved:

environment: 
  - PGADMIN_DEFAULT_EMAIL=osvaldotcf@gmail.com
  - PGADMIN_DEFAULT_PASSWORD=db1010aa..
  - "SCRIPT_NAME=/pgadmin4"
#  - 'PGADMIN_LISTEN_PORT=5050'      
ports: 
  - '80'
networks: 
  - rede_interna
volumes: 
  - pga4vol1:/root/.pgadmin
  - pga4vol2:/var/lib/pgadmin
labels:
  - "traefik.enable=true"
  - "traefik.http.routers.pgadmin4.rule=PathPrefix(`/pgadmin4`)"