Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fpm-alpine & volume (-v) leads to empty /var/www/html (Apache2) #395

Open
AndreasFagschlunger opened this issue Jan 31, 2023 · 4 comments
Open

Comments

@AndreasFagschlunger
Copy link

Sorry to raise this issue, but I have a problem using the fpm-alpine container with Apache2 installed on the host machine. I have the following line in my Apache2 to redirect *.php requests to fpm:

ProxyPassMatch "^/phpMyAdmin/(.*\.php)$" "fcgi://localhost:9002/var/www/html/$1"

This works well. The real problem are the resource files (CSS, JS), I usually use a volume to make them accessible through the host file system like this:

docker run -e PMA_HOST=host.docker.internal --name phpmyadmin --add-host host.docker.internal:host-gateway -v /var/www/phpmyadmin:/var/www/html -p 9000:9000 -d phpmyadmin:fpm-alpine

And then I would add this line in Apache2 to serve the resource files through the container:

Alias /phpMyAdmin /var/www/phpmyadmin

But when I mount a volume like this, the /var/www/html directory in the container is empty. There is also no /usr/src/phpmyadmin directory, only the /usr/src/php.tar.xz file exists.

This approach worked for me for other containers based on php-fpm-alpine, I don't know what is special about phpMyAdmin that it doesn't work here. So can anyone help me on howto setup this correctly?

And yes, I asked this question on Stackoverflow but I didn't get any response there.

@williamdes
Copy link
Member

Hi!
Where did you see something about /usr/src?

It's /var/www/html (

tar -xf phpMyAdmin.tar.xz -C /var/www/html --strip-components=1; \
) ,can you share your docker compose file?

I am currently thinking that there is no need to volume mount, and after that maybe it could be a local path issue sending the request to fpm

This works well. The real problem are the resource files (CSS, JS), I usually use a volume to make them accessible through the host file system like this:

Okay I get it, it works but no files are recognized by apache2 as tbey do not exist on the host file system

Hmm, maybe run the apache2 version and proxy the http traffic to it?

@williamdes
Copy link
Member

This relates to #362

All this was caused by #285

@williamdes
Copy link
Member

Can you link the stackoverflow.com post?

@AndreasFagschlunger
Copy link
Author

/usr/src/phpmyadmin was mentioned here: #253 (comment)

Stackoverflow post is here: https://stackoverflow.com/questions/75268068/problem-with-static-files-using-phpmyadminfpm-alpine-behind-apache2

Issue #362 seems to be the same issue. I use plain docker, so I don't have a docker compose file and Apache2 doesn't run within docker, but directly on the host system.

My understanding at this point is, Dockerfile-alpine.template extracts directly to /var/www/html and if this is part of a mounted volume (-v), the extraction doesn't work and /var/www/html is empty.

I think the steps to reproduce the problem are simple, start the container with a mount to /var/www/html:

docker run -e PMA_HOST=host.docker.internal --name phpmyadmin --add-host host.docker.internal:host-gateway -v /var/www/phpmyadmin:/var/www/html -p 9000:9000 -d phpmyadmin:fpm-alpine

And then check the /var/www/html directory on the container, it's empty:

docker exec -it phpmyadmin /bin/sh
/var/www/html # ls -al
total 0
drwxr-xr-x    2 root     root             6 Jan 31 20:28 .
drwxr-xr-x    1 root     root            18 Nov 12 08:36 ..
/var/www/html #

Run the container without mount (-v) and all the files are there:

docker exec -it phpmyadmin /bin/sh
/var/www/html # ls -al
total 672
drwxrwxrwx    1 www-data www-data      4096 Jan  6 05:22 .
drwxr-xr-x    1 root     root            18 Nov 12 08:36 ..
-rw-r--r--    1 root     root            20 May 11  2022 .rtlcssrc.json
-rw-r--r--    1 root     root         64403 May 11  2022 ChangeLog
-rw-r--r--    1 root     root         18092 May 11  2022 LICENSE
-rw-r--r--    1 root     root          1520 May 11  2022 README
-rw-r--r--    1 root     root          4759 May 11  2022 composer.json
-rw-r--r--    1 root     root        261656 May 11  2022 composer.lock
-rw-r--r--    1 root     root          4779 May 11  2022 config.sample.inc.php
drwxr-xr-x    3 root     root            18 May 11  2022 doc
-rw-r--r--    1 root     root         22486 May 11  2022 favicon.ico
-rw-r--r--    1 root     root          1074 May 11  2022 index.php
drwxr-xr-x    5 root     root            66 Jan  6 05:22 js
drwxr-xr-x    4 root     root          4096 Jan  6 05:22 libraries
drwxr-xr-x   44 root     root          4096 May 11  2022 locale
-rw-r--r--    1 root     root          2785 May 11  2022 package.json
-rw-r--r--    1 root     root            26 May 11  2022 robots.txt
-rw-r--r--    1 root     root          1153 May 11  2022 show_config_errors.php
drwxr-xr-x    2 root     root           141 May 11  2022 sql
drwxr-xr-x   25 root     root          4096 Jan  6 05:22 templates
drwxr-xr-x    6 root     root            83 May 11  2022 themes
drwxr-xr-x    2 www-data www-data         6 Jan  6 05:22 tmp
-rw-r--r--    1 root     root           965 May 11  2022 url.php
drwxr-xr-x   20 root     root          4096 May 11  2022 vendor
-rw-r--r--    1 root     root        249066 May 11  2022 yarn.lock

e.g., I also use postfixadmin which is small but similar in the structure:

The Dockerfile seems to extract everything to /usr/src/postfixadmin
https://github.com/postfixadmin/docker/blob/master/fpm-alpine/Dockerfile

Where the docker-entrypoint.sh then copies everything to /var/www/html
https://github.com/postfixadmin/docker/blob/master/fpm-alpine/docker-entrypoint.sh

This is what docker logs shows in case of postfixadmin:

Postfixadmin not found in /var/www/html - copying now...
WARNING: /var/www/html is not empty - press Ctrl+C now if this is an error!
...
Complete! Postfixadmin has been successfully copied to /var/www/html

I need access to the resource files, since fpm couldn't serve these files directly, this would result in following errors for any non php files:

172.17.0.1 -  31/Jan/2023:22:03:22 +0000 "GET /phpMyAdmin/index.php" 200
172.17.0.1 -  31/Jan/2023:22:03:22 +0000 "GET /phpMyAdmin/themes/pmahomme/jquery/jquery-ui.css" 403
NOTICE: Access to the script '/var/www/html/themes/pmahomme/jquery/jquery-ui.css' has been denied (see security.limit_extensions)
NOTICE: Access to the script '/var/www/html/js/vendor/codemirror/lib/codemirror.css' has been denied (see security.limit_extensions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants