设为首页 收藏本站
查看: 1382|回复: 0

[经验分享] 编译Nginx支持Tcp_warppers

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-8-13 10:11:27 | 显示全部楼层 |阅读模式




1、重新编译Nginx

[iyunv@ipython nginx-1.6.1]# tar zxf ../ngx_tcpwrappers.tar.gz -C ./
[iyunv@ipython nginx-1.6.1]# sed -i s'#CFLAGS =  -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g#CFLAGS =  -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -g#' objs/Makefile
[iyunv@ipython nginx-1.6.1]# ./configure --prefix=/software/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-google_perftools_module --with-debug --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre=/root/pcre-8.35 --with-openssl=/root/openssl-1.0.1i --with-zlib=/root/zlib-1.2.8 --add-module=./ngx_tcpwrappers
####不要make install 哦,编译好即可####
[iyunv@ipython nginx-1.6.1]# make



2、完成升级,以及模块的使用,Nginx还是很奇特的哦~~

####备份可执行文件,复制新的文件####
[iyunv@ipython nginx-1.6.1]# mv /software/nginx/sbin/nginx /software/nginx/conf/@nginx
[iyunv@ipython nginx-1.6.1]# cp objs/nginx /software/nginx/sbin/

####测试新版本的Nginx####
[iyunv@ipython nginx-1.6.1]# /software/nginx/sbin/nginx -t
nginx: the configuration file /software/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /software/nginx/conf/nginx.conf test is successful

###此时没有加入Tcp_wrappers的配置 测试下访问###
[iyunv@ipython openssl-1.0.1i]# curl -I http://www.ipython.me
HTTP/1.1 200 OK
Server: nginx/1.6.1
Date: Mon, 11 Aug 2014 23:08:08 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Mon, 11 Aug 2014 22:45:25 GMT
Connection: keep-alive
ETag: "53e94785-264"
Accept-Ranges: bytes

###平滑升级###
[iyunv@ipython nginx-1.6.1]# make upgrade

##测试模块,拒绝1.1.1.30的Nginx请求##    ##在http块里加入如下配置##
    tcpwrappers on;
    tcpwrappers_daemon nginx;
    tcpwrappers_thorough off;

##hosts.deny如下##
[iyunv@ipython nginx-1.6.1]# awk '!/^#/' /etc/hosts.deny
nginx:1.1.1.30

##重新读取Nginx配置文件##
[iyunv@ipython nginx-1.6.1]# /software/nginx/sbin/nginx -s reload

###此时访问 就是403了###
[iyunv@itchenyi ~]# curl -I http://www.ipython.me
HTTP/1.1 403 Forbidden
Server: nginx/1.6.1
Date: Mon, 11 Aug 2014 23:12:47 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive



3、Tcp_warppers 模块指令

###ngx_Tcp_wrappers 配置指令###
1、tcpwrappers
    语法    : tcpwrappers [on|off]
    默认值    : tcpwrappers off
    作用域    : http, server, location, limit_except
    描述    : 模块的开关,开启则使用TCP Wrappers 进行访问控制,关闭以避免浪费性能

2、tcpwrappers_daemon
    语法    : tcpwrappers_daemon name
    默认值    : tcpwrappers_daemon nginx
    作用域    : http, server, location, limit_except
    描述    : 该名字的定义用于在/etc/hosts.[allow|deny]识别

3、tcpwrappers_thorough
    语法    : tcpwrappers_thorough [on|off]
    默认值    : tcpwrappers_thorough off
    作用域    : http, server, location, limit_except
    描述    : 基于hosts.ctl以检查使用IP地址、用户名、反向DNS解析,模块的开发者也未提供详细的使用说明

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-23690-1-1.html 上篇帖子: nginx负载均衡配置 下篇帖子: Nginx 安装 --编译模块参数
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表