How to use in subdirectory #101

Closed
kujiy opened this Issue Dec 15, 2016 · 8 comments

Projects

None yet

2 participants

@kujiy
kujiy commented Dec 15, 2016

Is is possible that I launch it as http://example.com/phpmyadmin/ ?

PMA_ABSOLUTE_URI seemed not work.

@nijel
Member
nijel commented Dec 15, 2016

Do you use latest version, PMA_ABSOLUTE_URI sould be the way to do it, but it's not supported on anything older than 4.6.5.

@nijel nijel self-assigned this Dec 15, 2016
@nijel nijel added the question label Dec 15, 2016
@kujiy
kujiy commented Dec 15, 2016

Thanks @nijel I'll check the version tomorrow. I thought I excuted docker pull phpmyadmin/phpmyadmin:latest today. I was wondering that my container ran with php command not nginx and supervisor. I might take some mistakes...

@nijel
Member
nijel commented Dec 15, 2016

That sounds correcty, but if there is no supervisor, it's clearly some older version. Maybe I've made something wrong in the docker hub tags setup....

@kujiy
kujiy commented Dec 15, 2016

@nijel I feel that's understandable for me. I'd had old container at the moment so I did docker pull and docker rm -f container then docker-compose up. But there's no supervisor inside the container. I'd like to know your recommended tag, thanks.

@kujiy
kujiy commented Dec 16, 2016

Hi @nijel, I was wrong that I specified an old image in docker-compose.yml. I'm sorry to bother you. Now I launched the latest container Version 4.6.5.2. But PMA_ABSOLUTE_URI seemed not to work for subdirectory. I'm wondering where your subdirectory code is. My /etc/nginx.conf is completely same as its original, there's no alias. (I tried to add those lines but couldn't make it work... I've got to learn nginx first).

Could you tell me how you tried a web server to have an alias?

@nijel
Member
nijel commented Dec 16, 2016

The PMA_ABSOLUTE_URI doesn't change the path where phpMyAdmin is served from the container (it's always on /), it's there for possibility to run it behind reverse proxy which will change the location.

It's there for handing following setups:

(reverse proxy)         <->  (phpMyAdmin docker)
https://host/some/path/      http://1.2.3.4/

Here phpMyAdmin would think it's running on http://1.2.3.4/, while the user sees it at https://host/some/path/. In such case setting PMA_ABSOLUTE_URI=https://host/some/path/ is needed.

@kujiy
kujiy commented Dec 16, 2016

I used phpmyadmin behind haproxy so tried to setup haproxy as a ProxyPass and works!

Here's my haproxy settings for subdirectoried phpmyadmin .

frontend http
    bind *:80
    option forwardfor
    option http-server-close

    ### NETWORK restriction
    acl LOCALNET  src 10.0.0.0/8 192.168.0.0/16 172.16.0.0/12

    # /phpmyadmin
    acl phpmyadmin  path_dir /phpmyadmin
    use_backend phpmyadmin if phpmyadmin LOCALNET  

backend phpmyadmin
    mode http

    # ProxyPass /phpmyadmin/ http://172.30.21.21/
    reqirep  ^(GET|POST|HEAD)\ /phpmyadmin/(.*)     \1\ /\2 

    server localhost     172.30.21.21:80                # <- phpmyadmin container IP

Here's docker-compose.yml for phpmyadmin.

version: '2'

services:
  phpmyadmin:
    restart: always
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    hostname: phpmyadmin
    domainname: example.com
    ports:
      - 8000:80
    environment:
      - PMA_HOSTS=172.26.36.7,172.26.36.8,172.26.36.9,172.26.36.10
      - PMA_VERBOSES=production-db1,production-db2,dev-db1,dev-db2
      - PMA_USER=root
      - PMA_PASSWORD=
      - PMA_ABSOLUTE_URI=http://example.com/phpmyadmin/
    networks:
      example.com:
        ipv4_address: 172.30.21.21                # <- Specified container IP for haproxy

networks:
  example.com:
    external: true

Now they're working perfectly. Thank you very much. Would my settings be added to your document perhaps?

@nijel
Member
nijel commented Dec 16, 2016

Adding that to the docs could be useful, can you please document your setup for our docs? It's here: https://github.com/phpmyadmin/phpmyadmin/blob/master/doc/setup.rst#installing-using-docker

@nijel nijel added a commit to phpmyadmin/phpmyadmin that referenced this issue Feb 6, 2017
@nijel nijel Add Docker sample for haproxy and subpath
Fixes phpmyadmin/docker#101

Signed-off-by: Michal Čihař <michal@cihar.com>
f26d745
@nijel nijel added a commit to phpmyadmin/phpmyadmin that closed this issue Feb 6, 2017
@nijel nijel Add Docker sample for haproxy and subpath
Fixes phpmyadmin/docker#101

Signed-off-by: Michal Čihař <michal@cihar.com>
f26d745
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment