nginx添加模块
1.首先下载模块解压
2.添加模块
[root@jk]# cd /usr/src/nginx-1.16.1
[root@jk nginx-1.16.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --add-module=../echo-nginx-module-master
3.编译(别安装)
[root@jk nginx-1.16.1]# make
4.将安装位置下的objs/下面nginx替换原来的nginx/sbin/nginx(先备份)
[root@jk sbin]# mv nginx nginx.backup
[root@jk sbin]# mv /usr/src/nginx-1.16.1/objs/nginx .
[root@jk sbin]# ls
nginx nginx.backup
5.修改配置文件,验证模块效果
[root@jk html]# vim /usr/local/nginx/conf/nginx.conf
location /abc {
root html;
echo 'haha';
}
[root@jk html]# curl http://192.168.174.111/abc
haha
访问控制
用于location段
allow:设定允许哪台或哪些主机访问,多个参数间用空格隔开
deny:设定禁止哪台或哪些主机访问,多个参数间用空格隔开
在配置文件中
示例:
location / {
root html/zabbix;
index index.php;
allow 192.168.174.0/24;
deny all;
}