zoukankan      html  css  js  c++  java
  • nginx 特定目录禁止php执行

    LNMP有一个缺点就是目录权限设置上不如Apache,有时候网站程序存在上传漏洞或类似pathinfo的漏洞从而导致被上传了php木马,而给网站和服务器带来比较大危险。

    建议将网站目录的PHP权限去掉,当访问上传目录下的php文件时就会返回403错误。下面VPS侦探详细介绍如何把lnmp环境下去掉指定目录的PHP执行权限。

    1、单个目录去掉PHP执行权限

    location ~* /attachments/.*.(php|php5)?$ {
    deny all;
    }
    

     2、多个目录去掉PHP执行权限

    location ~* ^/(uploadfile|statics|secret|html)/.*.(php|php5)?$ {
    	deny all;
    }
    
    location ~* ^/phpsso_server/(uploadfile|html)/.*.(php|php5)?$ {
    	deny all;
    }
    

    添加完执行:/usr/local/nginx/sbin/nginx -t 测试配置文件

    执行:/usr/local/nginx/sbin/nginx -s reload 载入配置文件使其生效

  • 相关阅读:
    Seven Puzzle Aizu
    Cheese
    Curling 2.0
    Ball
    Property Distribution
    Red and Black
    Lake Counting
    Ants
    剑桥雅思写作高分范文ESSAY20
    剑桥雅思写作高分范文ESSAY19
  • 原文地址:https://www.cnblogs.com/mr-amazing/p/5220576.html
Copyright © 2011-2022 走看看