簡體   English   中英

Not Found from php:apache (在沒有Dockerfile的情況下運行)

[英]Not Found from php:apache (run without a Dockerfile)

甚至無法從該容器提供靜態文件。 我做錯了什么?

我在跑

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM