默认是开启日志的,我们可以在nginx.conf中配置日志格式log_format,存放路径。
- cat /etc/nginx/nginx.conf
-
在/etc/nginx/nginx.conf中加上
- autoindex off
-
保存,重启即可。
在/etc/nginx/nginx.conf中:
- # 去掉单个目录的php执行权限
- location ~/attachements/.*\.(php|php5)?$ {
- deny all;
- }
-
- # 去掉多个目录的php执行权限
- location ~/(attachments|upload)/.*\.(php|php5)?$ {
- deny all;
- }
-
1、以上的配置文件代码需要放到location ~.php{…}上面,如果放到下面是无效的。
2、attachments需要写相对路径,不能写绝对路径。
- cat /etc/nginx/conf.d/default.conf
-
也可能在其他配置文件,可以利用grep -rn “server_name” ./进行搜索。
- #将错误页面重定向到404.html页面
- error_page 400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506 /404.html;
- location = /404.html {
- #放错误页面的目录路径
- root /var/www/html
- }
-
- server_tokens off
-
- if($request_method !~^(GET|HEAD|POST)$) {
- return 444;
- }
-
- location /admin {
- deny 192.168.1.1; #拒绝IP
- allow 192.168.1.0/24; #允许IP
- allow 10.1.1.0/16; #允许IP
- deny all; #拒绝其他所有IP
- }
-
- user www-data
-