首页 > 解决方案 > 带有帮助 traefik 的代理 Web 界面

问题描述

我正在尝试使用分段 URL 代理 pgAdmin Web 界面。但我对此有一些问题。

当我使用以下 URL -> http://localhost/pgadmin访问浏览器时,它会将我重定向到以下 URL -> http://localhost/login?next=%2F。这是 pgAdmin 的内部路由。

我希望路由成为下一个http://localhost/pgadmin/login?next=%2F

你能告诉我我怎样才能做到这一点。

这是我的 docker-compose 配置的示例

version: '3.7'

services:

  traefik:
   image: traefik:v2.2
   container_name: traefik
   restart: always
   networks:
            applications_network:
                ipv4_address: 172.20.1.1
   ports:
    - "80:80"
    - "8080:8080"
   command: 
    - "--api.insecure=true --providers.docker"
    - "--api.insecure=true"
    - "--providers.docker=true"
    - "--providers.docker.exposedbydefault=false"
    - "--entrypoints.web.address=:80"
    - "--log.level=debug"
   volumes:
    - "/var/run/docker.sock:/var/run/docker.sock:ro"


  pgAdmin4:
   image: dpage/pgadmin4:latest
   container_name: pgAdmin4
   restart: always
   networks:
            applications_network:
                ipv4_address: 172.20.2.1
   ports:
    - "15432:80"
   environment:
    PGADMIN_DEFAULT_EMAIL: "admin@test.com"
    PGADMIN_DEFAULT_PASSWORD: "postgres"
   labels:
      - "traefik.enable=true"
      - "traefik.http.routers.pgAdmin4.rule=Host(`localhost`)"
      - "traefik.http.middlewares.pgAdmin4-prefix.stripprefix.prefixes=/pgadmin"
      - "traefik.http.routers.pgAdmin4.middlewares=pgAdmin4-prefix"
      - "traefik.http.routers.pgAdmin4.entrypoints=web"
      - "traefik.http.routers.pgAdmin4.service=pgAdmin4"
      - "traefik.http.services.pgAdmin4.loadbalancer.server.port=80"


networks:
    applications_network:
        name: applications_network
        ipam:
            driver: default
            config:
                - subnet: 172.20.0.0/16

提前致谢。

标签: dockerdocker-composewebserverdevopstraefik

解决方案


推荐阅读