Home > Enterprise >  Not Found from php:apache (run without a Dockerfile)
Not Found from php:apache (run without a Dockerfile)

Time:10-17

Can not serve even a static files from this container. What I'm doing wrong?

I'm running

docker run -d -p 8081:80 --name test -v "$PWD":/var/www/html php:apache

and reciving the next output trying to request any file from $PWD

Not Found
The requested URL was not found on this server.

Apache/2.4.51 (Debian) Server at 0.0.0.0 Port 8081

the $PWD content gets inside a container, but is not served

docker exec -it test ls -l /var/www/html
total 44
-rw-r--r-- 1 root root    65 Sep 22 12:59 checkserver.php
-rw-r--r-- 1 root root 16093 Sep 22 12:59 crest.php
-rw-r--r-- 1 root root  1024 Sep 22 12:59 crestcurrent.php
-rw-r--r-- 1 root root   217 Oct 14 08:45 index.html
-rw-r--r-- 1 root root   516 Sep 22 12:59 index.php
-rw-r--r-- 1 root root   488 Sep 22 12:59 install.php
-rw-r--r-- 1 root root   650 Sep 22 12:59 settings.php
-rw-r--r-- 1 root root     5 Oct 13 17:32 test.txt

CodePudding user response:

I used nginx as a reverse proxy before an Apache container. The problem was in nginx configuration. It started to work after I added the next lines to the configuration.

  location ~ \.php$ {
      proxy_set_header X-Real-IP  $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header Host $host;
      proxy_pass http://0.0.0.0:8081;
  }
  • Related