phpmyadmin / docker

Docker container for phpMyAdmin
https://hub.docker.com/_/phpmyadmin
GNU General Public License v3.0
675 stars 455 forks source link

fpm-alpine image is not working with nginx fastcgi_pass. #299

Closed woosungchoi closed 4 years ago

woosungchoi commented 4 years ago

docker-compose.yml

version: '3'

services:

  db:
    image: mariadb:latest
    container_name: db
    restart: unless-stopped
    env_file: .env
    environment:
    volumes:
      - ./data/dbdata:/var/lib/mysql
      - ./db:/docker-entrypoint-initdb.d

  nginx:
    image: nginx:alpine
    container_name: nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/logs:/var/log/nginx/
      - phpmyadmin:/var/www/html/phpmyadmin:ro

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:fpm-alpine
    container_name: phpmyadmin
    environment:
      - PMA_HOST=db
    restart: always
    depends_on:
      - db
    volumes:
      - phpmyadmin:/var/www/html

volumes: 
  phpmyadmin:

phpmyadmin.conf

server {
        listen 80;
        listen [::]:80;

        server_name pma.example.com;

        location / {
                rewrite ^ https://$host$request_uri? ;
        }
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name pma.example.com;

        root /var/www/html/phpmyadmin;

        index index.php index.html index.htm;

location ~ \.php$ {
       try_files $uri =404;
       fastcgi_split_path_info ^(.+\.php)(/.+)$;
       fastcgi_pass phpmyadmin:9000;
       fastcgi_index index.php;
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_param PATH_INFO $fastcgi_path_info;
        }

location ~ /\.ht {
        deny all;
}
location = /favicon.ico {
        log_not_found off; access_log off;
}
location = /robots.txt {
        log_not_found off; access_log off; allow all;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
}
include conf.d/ssl-conf; # ssl stuff
}

https://github.com/woosungchoi/docker-multi-site

Actually, I am using phpmyadmin as above, but I want to use fpm-alpine version to reduce the capacity. I am already using wordpress, gnuboard and rhymix in the same way. But not phpmyadmin.


https://github.com/phpmyadmin/docker/issues/253#issuecomment-543930024

I have already seen the comments in the link above. But it doesn't work.

How should I solve the problem?

williamdes commented 4 years ago

Hi @woosungchoi
I did not test your configuration due to a lack of time but what would you describe as "not working" ?

woosungchoi commented 4 years ago

Hi @woosungchoi
I did not test your configuration due to a lack of time but what would you describe as "not working" ?

@williamdes The container runs fine. However, when I connect, I get a 404 error.

williamdes commented 4 years ago

Hi @woosungchoi I did not test your configuration due to a lack of time but what would you describe as "not working" ?

@williamdes The container runs fine. However, when I connect, I get a 404 error.

I would recommend you to change root /var/www/html/phpmyadmin; into root /var/www/html; because of phpmyadmin:/var/www/html and https://github.com/phpmyadmin/docker/blob/9d66e78f8a442fcdf3e8379eb23fd12e26110ee1/Dockerfile-debian.template#L101

woosungchoi commented 4 years ago

@williamdes It works! thx!

woosungchoi commented 4 years ago

How to connect fpm-alpine image to nginx fastcgi_pass

docker-compose.yml

version: '3'

services:

  db:
    image: mariadb:latest
    container_name: db
    restart: unless-stopped
    env_file: .env
    environment:
    volumes:
      - ./data/dbdata:/var/lib/mysql

  nginx:
    image: nginx:alpine
    container_name: nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/logs:/var/log/nginx/
      - phpmyadmin:/var/www/html

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:fpm-alpine
    container_name: phpmyadmin
    environment:
      - PMA_HOST=db
    restart: always
    depends_on:
      - db
    volumes:
      - phpmyadmin:/var/www/html

volumes: 
  phpmyadmin:

./nginx/conf.d/phpmyadmin.conf

server {
        listen 80;
        listen [::]:80;

        server_name pma.example.com;

        location / {
                rewrite ^ https://$host$request_uri? ;
        }
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name pma.example.com;

        root /var/www/html;

        index index.php index.html index.htm;

location ~ \.php$ {
       try_files $uri =404;
       fastcgi_split_path_info ^(.+\.php)(/.+)$;
       fastcgi_pass phpmyadmin:9000;
       fastcgi_index index.php;
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_param PATH_INFO $fastcgi_path_info;
        }

location ~ /\.ht {
        deny all;
}
location = /favicon.ico {
        log_not_found off; access_log off;
}
location = /robots.txt {
        log_not_found off; access_log off; allow all;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
}
include conf.d/ssl-conf; # ssl stuff
}

It works perfectly fine. @williamdes