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

作者:袖梨 2022-06-30

针对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;
}
}

相关文章

精彩推荐