nginx基础配置

nginx基础配置目录nginx添加模块nginx添加模块1.首先下载模块解压2.添加模块[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 ...
摘要由CSDN通过智能技术生成

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;
        }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值