0
我使用的是OctoberCMS,基於Laravel和Twig,以及Nginx和PHP7.0-FPM。使用Nginx在OctoberCMS中限制.htm頁面和部分
如果我訪問本地主機:8888 /我的頁面,PHP呈現,但源被隱藏。
但是,如果我訪問localhost:8888/themes/mysite/pages/mypage.htm我可以在瀏覽器中查看所有php源代碼。
據說這是爲了限制訪問這些文件http://octobercms.com/docs/setup/configuration#nginx-configuration
但它不工作。我把它放在我的網站 - 可用並重新啓動Nginx。我仍然可以訪問.htm文件。
我的Nginx網站可用:
server {
listen 80;
server_name localhost:8888;
root /var/www/mysite/public;
index index.html index.htm index.php;
location/{
try_files $uri $uri/ /index.php$is_args$args;
include /etc/nginx/mime.types;
}
rewrite ^themes/.*/(layouts|pages|partials)/.*.htm /index.php break;
rewrite ^bootstrap/.* /index.php break;
rewrite ^config/.* /index.php break;
rewrite ^vendor/.* /index.php break;
rewrite ^storage/cms/.* /index.php break;
rewrite ^storage/logs/.* /index.php break;
rewrite ^storage/framework/.* /index.php break;
rewrite ^storage/temp/protected/.* /index.php break;
rewrite ^storage/app/uploads/protected/.* /index.php break;
location ~ \.php$ {
# With php7-fpm:
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi.conf;
}
# Support Search Engine Friendly URLs
location ~/{
try_files $uri $uri/ /index.php?q=$request_uri;
include /etc/nginx/mime.types;
}
# Deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
}