新的centos虚拟机
1. 安装openresty
wget https://openresty.org/package/centos/openresty.repo sudo mv openresty.repo /etc/yum.repos.d/ sudo yum check-update sudo yum install -y openresty sudo yum install -y openresty-resty安装开发库
yum install pcre-devel openssl-devel gcc curl下载最新版本openresty源码 https://openresty.org/download/openresty-1.19.3.1.tar.gz
tar -xzvf openresty-1.19.3.1.tar.gz cd openresty-1.19.3.1/ ./configure gmake gmake install
这是默认安装位置
2. 修改nginx.conf 配置文件引入waf
lua_shared_dict limit 10m; lua_package_path "/usr/local/openresty/nginx/conf/waf/?.lua"; init_by_lua_file "/usr/local/openresty/nginx/conf/waf/init.lua"; access_by_lua_file "/usr/local/openresty/nginx/conf/waf/access.lua";
添加PATH
PATH=/usr/local/openresty/nginx/sbin:$PATH export PATH
下载waf
git clone https://github.com/unixhot/waf.git cp -a ./waf/waf /usr/local/openresty/nginx/conf/
报错:
lua_package_path "/usr/local/openresty/nginx/conf/waf/?.lua;/usr/local/openresty/lua-resty-core/lib/?.lua;;";启动nginx, “conf/nginx.conf”代表要启动时的配置文件,这里是相对路径,也可以不带
nginx -p `pwd`/ -c conf/nginx.conf
成功 这里我改了html文件,只要能访问即代表成功
成功 这里我改了html文件,只要能访问即代表成功
这是conf/waf/config.lua文件,里面选项代表开启的功能,config_output_html为拦截后显示的页面
测试:
拦截成功
如果想要在其他机器中访问虚拟机搭建的网站,要关闭虚拟机中的防火墙
systemctl stop firewalld.service && systemctl disable firewalld.service