【问题标题】:Not Found from php:apache (run without a Dockerfile)Not Found from php:apache (在没有 Dockerfile 的情况下运行)
【发布时间】:2021-10-14 09:39:48
【问题描述】:

甚至无法从该容器中提供静态文件。我做错了什么?

我在跑步

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

并接收下一个输出尝试从 $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

$PWD 内容进入容器,但未被提供

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

【问题讨论】:

    标签: php docker apache


    【解决方案1】:

    我在 Apache 容器之前使用 nginx 作为反向代理。问题出在 nginx 配置中。在我将下一行添加到配置后它开始工作。

      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;
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-21
      • 2020-08-23
      • 2018-06-06
      • 2016-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多