docker 컨테이너에서 nginx를 실행 중입니다. 개인 파일과 프로젝트에 액세스하려면 서브 디렉토리 /web/
을 갖고 싶습니다. 그것은 또한 PHP를 지원해야합니다.Nginx 서브 디렉토리 루트 (PHP 포함)
다음은 내가 실행하고있는 내용이지만 domain-a.com/web
은 404를 유지합니다. 동일한 PHP 블록이 서브 도메인에서 작동하지만 직접적으로 server{}
블록에서 작동하므로 PHP가 작동하는 것으로 확인되었습니다. 파일이 /etc/nginx/www
에있는 경우
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 /')에 있습니까? –
@RichardSmith 아니요, 그들은'/ etc/nginx/www /'에 있습니다 – Bob