一聚教程网:一个值得你收藏的教程网站

热门教程

nginx服务器简单的白名单设置

时间:2022-06-30 18:47:47 编辑:袖梨 来源:一聚教程网

针对php设置一个可执行的白名单,对于服务器安全来说也是一种必要而重要的设置。
其他的不多说,直接上配置明细吧:

 代码如下 复制代码

server {
    listen       5080;
    server_name  www.111com.net;
    root         /home/htdocs/app/;
    index        index.php;
    location / {
        try_files $uri $uri/ /index.php?s=$uri;
    }
    location ~ .*.php$ {
        # 白名单配置,只允许/index.php访问
        if ($fastcgi_script_name !~* "^/(index).php$") {
            return 403;
        }
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include        fcgi.conf;
    }
 }

热门栏目