ドッカーコンテナにnginxを実行しています。個人的なファイルやプロジェクトにアクセスするために、サブディレクトリ/web/
が必要です。また、PHPをサポートする必要があります。Nginxのサブディレクトリルート(PHPの場合)
以下は私が実行しているものですが、domain-a.com/web
の結果は404です。同じPHPブロックがサブドメインで動作しますが、server{}
ブロックで動作することが確認されています。
http {
server {
listen 443 ssl;
server_name domain-a.com domain-b.com;
# Mime types
include /etc/nginx/confs/mime.types;
# SSL
include /etc/nginx/confs/nginx-ssl.conf;
# Proxy to organizr
# This works
location/{
proxy_pass http://organizr/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_set_header Connection "";
}
# Root folder for my personal files/projects
# Doesn't work
location /web {
index index.php index.html;
root /etc/nginx/www;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
}
}
ファイルはサブディレクトリ、つまり '/ etc/nginx/www/web /'にもありますか? –
@リチャードスミスいいえ、彼らは '/ etc/nginx/www /'にあります。 – Bob