Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up phpmyadmin with traefik2 in docker

I am having some trouble accessing my phpmyadmin through traefik2 reverse proxy! all the other apps I am using in my docker-compose are working correctly through traefik. Its as simple as setting the labels up, specififying which domain to use, and then going to that through a browser. Right now I am able to access phpmyadmin through the local ip and port, but unable to through my domain. I just get a 404 not found error. This is my phpmyadmin docker-compose setup.

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    depends_on:
      - mariadb
    container_name: phpmyadmin
    restart: unless-stopped
    networks:
      - t2_proxy
    security_opt:
      - no-new-privileges:true
#    volumes:
#      - $USERDIR/docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
    environment:
      - PMA_PORT=$DB_PORT
      - PMA_HOST=$MYSQL_HOST
#      - PMA_ABSOLUTE_URI=$ABSOLUTE_URI
#      - PMA_ARBITRARY=1
      - MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
    ports:
      - $PHPMYADMIN_PORT:80
    labels:
      - "traefik.enable=true"
#      - "traefik.backend=phpmyadmin"
      ## HTTP Routers
      - "traefik.http.routers.phpmyadmin-rtr.entrypoints=https"
      - "traefik.http.routers.phpmyadmin-rtr.rule=Host(`phpmyadmin.$DOMAINNAME`)"
      ## Middlewares
      - "traefik.http.routers.phpmyadmin-rtr.middlewares=chain-oauth@file"
      ## HTTP Services
      - "traefik.http.routers.phpmyadmin-rtr.service=phpmyadmin-svc"
      - "traefik.http.services.phpmyadmin-svc.loadbalancer.server.port=80"

I am also getting a very similar error with my php/apache container that I can access locally but not through traefik. All the other containers have been a simple swap of the labels, rename them and boom, they are accessible ! what am I doing wrong? I tried adding PMA_ABSOLUTE_URI=$ABSOLUTE_URI and I can't figure out how to enable ssl in phpmyadmin in docker.

and it still doesnt work but phpmyadmin says:

There is a mismatch between HTTPS indicated on the server and client. This can lead to a non working phpMyAdmin or a security risk. Please fix your server configuration to indicate HTTPS properly.

And also for my apache server it is setup like this, with a similar problem where it can be accessed from localhost but not traefik!

  apache:
    build:
      context: $USERDIR/docker/apache
      dockerfile: Dockerfile
    container_name: apache
    volumes:
      - $USERDIR/WEBSITE:/var/www/html/
    ports:
      - 6546:80
    labels:
      - "traefik.enable=true"
      ## HTTP Routers
      - "traefik.http.routers.apache-rtr.entrypoints=https"
#      - "traefik.http.routers.tautulli-rtr.rule=Host(`web.$DOMAINNAME`)"
      - "traefik.http.routers.apache-rtr.rule=Host(`$SECONDDOMAINNAME`)"
      ## Middlewares
      - "traefik.http.routers.apache-rtr.middlewares=chain-no-auth@file"
      ## HTTP Services
      - "traefik.http.routers.apache-rtr.service=apache-svc"
      - "traefik.http.services.apache-svc.loadbalancer.server.port=80"

sorry if this is alot, I am very new to docker, and really trying to figure this out! If i posted this in the wrong spot or something, let me know!

and if you need anymore information, please also let me know!

like image 835
Chase Avatar asked Jun 12 '26 10:06

Chase


1 Answers

Try adding in the label - "traefik.http.routers.phpmyadmin-rtr.tls=true"

This fixed the issue for me

like image 167
L.T Avatar answered Jun 13 '26 23:06

L.T



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!