[英]Unable to access PHP files sitting outside the document root of an nginx site
[英]Nginx: How to access files outside of root using PHP?
最初,我在/ var / www / html根文件夾中有一堆文件夾,這些文件夾受以下location
塊保護:
location ~ /(folder1|folder2|folder3) {
internal;
}
但是現在我意識到,如果我將它們完全從我的根文件夾中取出,那將更有意義。 我希望能夠通過PHP文件發送這些文件,而我正在這樣做:
$file_path = '/' . $path . '/' . $prefix . '.' . $suffix;
header('X-Accel-Redirect: ' . $file_path);
header("Content-Type: text/plain");
但是,如果我將這些文件夾放在/ var / www / html之外並放在/ var / www / protected中,該如何在PHP中訪問這些文件?
您可以使用root ...
在位置標記中進行區分...您可以在此處使用auth_request
獲得更多選項auth_request nginx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.