我正在尝试使用 Docker 在我的服务器上运行 MyBB 论坛软件,我的服务器上已经运行了 NGINX 来提供其他内容。
这就是我docker-compose.yml
现在的样子(我已经改变和测试东西有一段时间了...):
services:
mybb:
image: mybb/mybb:latest
volumes:
- ${PWD}/mybb:/var/www/html:rw
ports:
- "9000:9000"
postgresql:
environment:
POSTGRES_DB: mybb
POSTGRES_PASSWORD: password
POSTGRES_USER: mybb
image: postgres:13.2-alpine
volumes:
- ${PWD}/postgres/data:/var/lib/postgresql/data:rw
version: '3.7'
这个特定域的 NGINX 配置文件如下所示:
upstream mybb {
server 172.20.0.2:9000 weight=5;
}
server {
listen 80;
listen [::]:80;
root /home/lobo/mybb_docker/mybb;
index index.html index.php;
server_name mydomain.com www.mydomain.com;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ inc/ {
internal;
}
location ~ ^/(images|cache|jscripts|uploads)/ {
access_log off;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass mybb;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
我也一直在改变这里的东西...我尝试了不同的 IP 地址:127.0.0.1:9000
,0.0.0.0:9000
...
但我无法让它工作。当我访问该网站时,它只是返回:File not found.
我明显做错了什么吗?或者我还可以尝试其他什么吗?
谢谢你!!
编辑:添加/var/log/nginx/error.log
:
2021/04/09 10:04:56 [error] 19714#19714: *3705 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: xx.xx.xx.xx, server: mydomain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://172.20.0.2:9000", host: "www.mydomain.com"
答案1
容器看到的目录结构可能与运行 Nginx 的主机上的目录结构不同,从而导致 SCRIPT_FILENAME 和 PATH_INFO 无效。