有一个php项目doc,doc目录下面有很多目录,我想通过nginx禁止对目录访问,文件不影响,加入下面这段没有达到效果,请问有什么其他写法吗,谢谢!
#location ~* /(public|web_src/(build/config))/ {
# deny all;
# return 403;
#}
server {
listen 80;
server_name aaa.com;
location / {
rewrite ^/(.*)$ /doc/$1 last;
}
location ~* ^/doc/.*$ {
proxy_pass http://127.0.0.1:8080;
}
}
既然是 PHP 项目,所有的请求都应该通过入口文件来访问,如果你没有写路由到 doc 下,怎么会暴露呢?而且 Nginx autoindex 默认应该时关的。