编译Nginx支持Tcp_wrappers

编译Nginx支持Tcp_wrappers

务提供了增强的安全性。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.  
  4. [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
  5. ####不要make install 哦,编译好即可####
  6. [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.  
  5. ####测试新版本的Nginx####
  6. [root@ipython nginx-1.6.1]# /software/nginx/sbin/nginx -t
  7. nginx: the configuration file /software/nginx/conf/nginx.conf syntax is ok
  8. nginx: configuration file /software/nginx/conf/nginx.conf test is successful
  9.  
  10. ###此时没有加入Tcp_wrappers的配置 测试下访问###
  11. [root@ipython openssl-1.0.1i]# curl -I http://www.ipython.me
  12. HTTP/1.1 200 OK
  13. Server: nginx/1.6.1
  14. Date: Mon, 11 Aug 2014 23:08:08 GMT
  15. Content-Type: text/html
  16. Content-Length: 612
  17. Last-Modified: Mon, 11 Aug 2014 22:45:25 GMT
  18. Connection: keep-alive
  19. ETag: "53e94785-264"
  20. Accept-Ranges: bytes
  21.  
  22. ###平滑升级###
  23. [root@ipython nginx-1.6.1]# make upgrade
  24.  
  25. ##测试模块,拒绝1.1.1.30的Nginx请求## ##在http块里加入如下配置##
  26. tcpwrappers on;
  27. tcpwrappers_daemon nginx;
  28. tcpwrappers_thorough off;
  29.  
  30. ##hosts.deny如下##
  31. [root@ipython nginx-1.6.1]# awk '!/^#/' /etc/hosts.deny
  32. nginx:1.1.1.30
  33.  
  34. ##重新读取Nginx配置文件##
  35. [root@ipython nginx-1.6.1]# /software/nginx/sbin/nginx -s reload
  36.  
  37. ###此时访问 就是403了###
  38. [root@itchenyi ~]# curl -I http://www.ipython.me
  39. HTTP/1.1 403 Forbidden
  40. Server: nginx/1.6.1
  41. Date: Mon, 11 Aug 2014 23:12:47 GMT
  42. Content-Type: text/html
  43. Content-Length: 168
  44. 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.  
  8. 2、tcpwrappers_daemon
  9. 语法 : tcpwrappers_daemon name
  10. 默认值 : tcpwrappers_daemon nginx
  11. 作用域 : http, server, location, limit_except
  12. 描述 : 该名字的定义用于在/etc/hosts.[allow|deny]识别
  13.  
  14. 3、tcpwrappers_thorough
  15. 语法 : tcpwrappers_thorough [on|off]
  16. 默认值 : tcpwrappers_thorough off
  17. 作用域 : http, server, location, limit_except
  18. 描述 : 基于hosts.ctl以检查使用IP地址、用户名、反向DNS解析,模块的开发者也未提供详细的使用说明

 原文发布时间:2014-08-17

本文来自云栖合作伙伴“linux中国”

时间: 2024-07-28 12:36:28

编译Nginx支持Tcp_wrappers的相关文章

linux中编译Nginx支持Tcp_wrappers方法

Tcp wrappers : Transmission Control Protocol (TCP) Wrappers 为由 inetd 生成的服务提供了增强的安全性.TCP Wrappers 是一种对使用 /etc/inetd.sec 的替换方法.TCP Wrappers 提供防止主机名和主机地址欺骗的保护.欺骗是一种伪装成有效用户或主机以获得对系统进行未经授权的访问的方法.  1.重新编译Nginx  代码如下 复制代码 [root@ipython nginx-1.6.1]# tar zxf

源码编译更新nginx到最新版本,并开始nginx支持http2协议模块.

最近因为迁移公司vm上的代码,遇到一些问题.有一台vm配置了https协议,原以为迁移安全证书以后,配置nginx就可以了,但是修改nginx配置文件以后,执行 nginx -t 命令后,报如下错误: nginx: [warn] invalid parameter "spdy": ngx_http_spdy_module was superseded by ngx_http_v2_module in /usr/local/nginx/conf/sites-enable 在网上googl

CentOS7 配置Nginx支持HTTPS访问的实现方案_Linux

CentOS7配置Nginx支持HTTPS访问 1.安装git和bc yum -y install git bc 2.安装Nginx     1.准备:       yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel     2.下载:       wget https://nginx.org/download/nginx-1.11.6.tar.gz     3.解压:     tar zxvf

编译Nginx的http2,并解决http2中的错误问题

必要的准备 你需要有一个 https 证书. 需要安装 OpenSSl . nginx 的版本最大于等于 1.9.5 . 安装 1.下载并编译 nginx wget http://nginx.org/download/nginx-1.9.12.tar.gz tar zxf nginx-1.9.12.tar.gz cd nginx* 2.使用 patch 命令打补丁 yum install patch wget http://nginx.org/patches/http2/patch.http2.

编译Nginx提示error: the HTTP gzip module requires the zlib library

最近也玩nginx,编译nginx的时候出现提示下面: ./configure: error: the HTTP gzip module requires the zlib library.You can either disable the module by using –without-http_gzip_moduleoption, or install the zlib library into the system, or build the zlib librarystaticall

Linux系统配置nginx支持.cig的步骤

word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">说明: 操作系统:CentOS 6.x web环境:php+nginx+mysql nginx安装目录:/usr/local/nginx nginx配置文件:/usr/local/nginx/conf/nginx.conf nginx默认站点目录:/usr/local/nginx/html/

linux中修改Nginx For Tcp_wrappers返回444

前几天通过Tcp_wrappers阻止一些分析出来的恶意IP效果还是有的-不过我后面仍发现会占用一些流量,故此我想通过返回444这种非标准的状态码,减小流量的使用   默认情况下开启模块仅会返回403  代码如下 复制代码 [root@ipython conf]# curl -I http://www.111cn.net HTTP/1.1 403 Forbidden Server: nginx/1.6.1 Date: Fri, 15 Aug 2014 14:52:13 GMT Content-T

让Apache 和nginx支持跨域访问

1,如何让Apache支持跨域访问呢? 步骤: 修改httpd.conf,windows中对应的目录是:C:\wamp\bin\apache\Apache2.4.4\conf\httpd.conf 把LoadModule headers_module modules/mod_headers.so 前面的注释删除 修改 改为: 即: <Directory /> AllowOverride none Require all granted Header set Access-Control-All

nginx 编译-win7下编译nginx,添加h264.streaming包,编译报错

问题描述 win7下编译nginx,添加h264.streaming包,编译报错 如题, win7下编译nginx,添加h264.streaming包,编译报错 如何解决啊? 解决方案 具体编译错误信息是什么?这才好分析 解决方案二: http://www.07net01.com/program/310922.html 解决方案三: 解决方案四: 解决方案五: 使用最新版本的吧,不用自己再编译了