最新消息:iOS编程开发交流群(6906921) ,Mac.Cocoa开发交流群(7758675) 欢迎iOS/macOS开发编程爱好及学习者加入!

linux上nginx防止.htaccess被下载

Linux 天狐 9393浏览 0评论

今天阿里云盾提示我"系统配置泄露"查看发现.htaccess可以直接下载

默认情况下nginx的vhost配置是没禁止.htaccess文件访问的,所以通过url也可以当作一个文件访问到

禁止方法很简单

vi  /nginx/conf/vhost/skyfox.org.conf

增加以下代码即可

location ~ ^.*\.(htaccess|htpasswd|ini|php|sh)$ {
  deny all;
}
server {
        listen       80;
        server_name skyfox.org skyfox.org www.skyfox.org;
        root /mnt/wwwroot/skyfox_org/;
        index  index.html index.php index.htm;
     
        location ~ \.php$ {
                proxy_pass http://127.0.0.1:88;
                include naproxy.conf;
        }
        location / {
                try_files $uri @apache;
        }
        location @apache {
                 proxy_pass http://127.0.0.1:88;
                 include naproxy.conf;
        }
        location ~ ^.*\.(htaccess|htpasswd|ini|php|sh)$ {
              deny all;
        }
}

 

F8632820-916E-4804-9E76-615530C0B3AA

转载请注明:天狐博客 » linux上nginx防止.htaccess被下载

微信 OR 支付宝 扫描二维码
为天狐 打赏
非常感谢你的支持,哥会继续努力!
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址