你好,游客 登录 注册 搜索
背景:
阅读新闻

编译Nginx支持Tcp_wrappers

[日期:2014-08-17] 来源:IT辰逸  作者:IT辰逸 [字体:大 中 小]

Tcp wrappers :Transmission Control Protocol (TCP) Wrappers 为由 inetd 生成的服务提供了增强的安全性。Tcp wrappers是一种对使用 /etc/inetd.sec 的替换方法。TCP Wrappers 提供防止主机名和主机地址欺骗的保护。欺骗是一种伪装成有效用户或主机以获得对系统进行未经授权的访问的方法。

1、重新编译Nginx

  1. [root@ipython nginx-1.6.1]# tar zxf ../ngx_tcpwrappers.tar.gz -C ./
  2. [root@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
  3. [root@ipython nginx-1.6.1]# sed -i s'#CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror#CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -g#' objs/Makefile
  4. ####不要make install 哦,编译好即可####
  5. [root@ipython nginx-1.6.1]# make

 

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

  1. ####备份可执行文件,复制新的文件####
  2. [root@ipython nginx-1.6.1]# mv /software/nginx/sbin/nginx /software/nginx/conf/@nginx
  3. [root@ipython nginx-1.6.1]# cp objs/nginx /software/nginx/sbin/
  4. ####测试新版本的Nginx####
  5. [root@ipython nginx-1.6.1]#/software/nginx/sbin/nginx -t
  6. nginx: the configuration file /software/nginx/conf/nginx.conf syntax is ok
  7. nginx: configuration file /software/nginx/conf/nginx.conf test is successful
  8. ###此时没有加入Tcp_wrappers的配置 测试下访问###
  9. [root@ipython openssl-1.0.1i]# curl -I http://www.ipython.me
  10. HTTP/1.1200 OK
  11. Server: nginx/1.6.1
  12. Date:Mon,11Aug201423:08:08 GMT
  13. Content-Type: text/html
  14. Content-Length:612
  15. Last-Modified:Mon,11Aug201422:45:25 GMT
  16. Connection: keep-alive
  17. ETag:"53e94785-264"
  18. Accept-Ranges: bytes
  19. ###平滑升级###
  20. [root@ipython nginx-1.6.1]# make upgrade
  21. ##测试模块,拒绝1.1.1.30的Nginx请求## ##在http块里加入如下配置##
  22. tcpwrappers on;
  23. tcpwrappers_daemon nginx;
  24. tcpwrappers_thorough off;
  25. ##hosts.deny如下##
  26. [root@ipython nginx-1.6.1]# awk '!/^#/'/etc/hosts.deny
  27. nginx:1.1.1.30
  28. ##重新读取Nginx配置文件##
  29. [root@ipython nginx-1.6.1]#/software/nginx/sbin/nginx -s reload
  30. ###此时访问 就是403了###
  31. [root@itchenyi ~]# curl -I http://www.ipython.me
  32. HTTP/1.1403Forbidden
  33. Server: nginx/1.6.1
  34. Date:Mon,11Aug201423:12:47 GMT
  35. Content-Type: text/html
  36. Content-Length:168
  37. Connection: keep-alive

 

3、Tcp_warppers 模块指令

  1. ###ngx_Tcp_wrappers 配置指令###
  2. 1、tcpwrappers
  3. 语法: tcpwrappers [on|off]
  4. 默认值: tcpwrappers off
  5. 作用域: http, server, location, limit_except
  6. 描述:模块的开关,开启则使用TCP Wrappers进行访问控制,关闭以避免浪费性能
  7. 2、tcpwrappers_daemon
  8. 语法: tcpwrappers_daemon name
  9. 默认值: tcpwrappers_daemon nginx
  10. 作用域: http, server, location, limit_except
  11. 描述:该名字的定义用于在/etc/hosts.[allow|deny]识别
  12. 3、tcpwrappers_thorough
  13. 语法: tcpwrappers_thorough [on|off]
  14. 默认值: tcpwrappers_thorough off
  15. 作用域: http, server, location, limit_except
  16. 描述:基于hosts.ctl以检查使用IP地址、用户名、反向DNS解析,模块的开发者也未提供详细的使用说明

--------------------------------------分割线 --------------------------------------

CentOS 6.2实战部署Nginx+MySQL+PHP http://www.linuxidc.com/Linux/2013-09/90020.htm

使用Nginx搭建WEB服务器 http://www.linuxidc.com/Linux/2013-09/89768.htm

搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm

CentOS 6.3下Nginx性能调优 http://www.linuxidc.com/Linux/2013-09/89656.htm

CentOS 6.3下配置Nginx加载ngx_pagespeed模块 http://www.linuxidc.com/Linux/2013-09/89657.htm

CentOS 6.4安装配置Nginx+Pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm

Nginx安装配置使用详细笔记 http://www.linuxidc.com/Linux/2014-07/104499.htm

Nginx日志过滤 使用ngx_log_if不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm

--------------------------------------分割线 --------------------------------------

Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里

来自:http://www.ipython.me/centos/rebuild-nginx-support-tcp_wrappers.html    作者: IT辰逸

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-08/105663.htm

linux
相关资讯       tcp_wrappers  Nginx编译 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款