Dear developers, team members, community members,
I am very sorry to bother you. I go crazy...
Isn't it possible - if I only use traefik locally - to reroute a sub path to pgadmin?... while the api still stays there at the configured prefix?
This doesn't lead to a priority issue right if different subpat prefixes are used?
I want localhost:81/pgadmin (fully working)
and localhost:81/api/v1/....... (wich already works)
I have following docker-compose file:
version: '3'
services:
traefik:
image: "traefik:v2.2"
container_name: "traefik"
command:
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=true"
- "--entrypoints.web.address=:81"
ports:
- "81:81"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
api:
labels:
- traefik.http.routers.api.rule=PathPrefix(`/api`)
image: sp33c/python:3.7
ports:
- 8081:5000
container_name: api
volumes:
- .:/app
command: "./production.sh"
postgres:
image: postgres:12.0-alpine
environment:
- POSTGRES_PASSWORD=dbpasswd
- POSTGRES_USER=dbuser
- POSTGRES_DB=appdb
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- .:/var/lib/postgresql/data
container_name: postgres
pgadmin:
image: dpage/pgadmin4
labels:
- "traefik.enable=true"
- "traefik.http.routers.pgadmin.rule=PathPrefix(`/pgadmin`)"
- "traefik.http.middlewares.pgadmin.stripprefix.prefixes=/pgadmin"
- "traefik.http.middlewares.pgadmin.stripprefix.forceslash=false"
environment:
- PGADMIN_DEFAULT_EMAIL=info@xxxx.tech
- PGADMIN_DEFAULT_PASSWORD=xxxxx
volumes:
- ./servers.json:/pgadmin4/servers.json
ports:
- 8082:80
container_name: pgadmin
Do you know what I do wrong?
warm regards,
Alex
cakiwi
June 20, 2020, 1:56pm
2
Welcome @afitterling
You don't really specify what is not working for you.
The api service does not have traefik.enable=true
set. Do that could be one thing that is an issue.
There is a section on pgAdmin for reverse proxying pgadmin and it has a section on traefik!
It looks like you need to specify another environment variable:
SCRIPT_NAME=/pgadmin
Thank you. Also for pointing out I was not precise. What did not work was pgadmin was not reachable under /pgadmin only the api under its appropriate route. I could see however in the logs, that the problem was related to flask inside pgadmin. So the service was triggered but not working or misconfigured.
This works now:
Thank you so much!!!
the - "traefik.enable=true" is not needed because of auto discover.
my docker-compose.yml:
``
version: '3'
services:
traefik:
image: "traefik:v2.2"
container_name: "traefik"
command:
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=true"
- "--entrypoints.web.address=:81"
ports:
- "81:81"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
#- "./traefik.toml:/etc/traefik/traefik.toml"
#- "./traefik.yaml/:/etc/traefik/traefik.yaml"
api:
labels:
#- "traefik.enable=true"
- traefik.http.routers.api.rule=PathPrefix(`/api`)
image: sp33c/python:3.7
ports:
- 8081:5000
container_name: api
volumes:
- .:/app
command: "./production.sh"
postgres:
image: postgres:12.0-alpine
environment:
- POSTGRES_PASSWORD=dbpasswd
- POSTGRES_USER=dbuser
- POSTGRES_DB=appdb
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- .:/var/lib/postgresql/data
container_name: postgres
pgadmin:
image: dpage/pgadmin4
labels:
#- "traefik.enable=true"
- "traefik.http.routers.pgadmin.rule=PathPrefix(`/pgadmin`)"
- "traefik.http.middlewares.pgadmin.stripprefix.prefixes=/pgadmin"
- "traefik.http.middlewares.pgadmin.stripprefix.forceslash=false"
environment:
- PGADMIN_DEFAULT_EMAIL=info@sp33c.tech
- PGADMIN_DEFAULT_PASSWORD=prinus
- SCRIPT_NAME=/pgadmin
volumes:
- ./servers.json:/pgadmin4/servers.json
ports:
- 8082:80
container_name: pgadmin
``
cakiwi
June 20, 2020, 5:08pm
4
Indeed, I was too quick in skimming it. I saw traefik.enable
in the pgdmin service and made an assumption - "--providers.docker.exposedbydefault=true"
was set to false!