Tcp wrappers : Transmission Control Protocol (TCP) Wrappers 爲由 inetd 生成的服務提供了加強的安全性。TCP Wrappers 是一種對使用 /etc/inetd.sec 的替換方法。TCP Wrappers 提供防止主機名和主機地址欺騙的保護。欺騙是一種假裝成有效用戶或主機以得到對系統進行未經受權的訪問的方法。html
一、從新編譯Nginxpython
[root@ipython nginx-1.6.1]# tar zxf ../ngx_tcpwrappers.tar.gz -C ./ [root@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 [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 ####不要make install 哦,編譯好便可#### [root@ipython nginx-1.6.1]# make
二、完成升級,以及模塊的使用,Nginx仍是很奇特的哦~~nginx
####備份可執行文件,複製新的文件#### [root@ipython nginx-1.6.1]# mv /software/nginx/sbin/nginx /software/nginx/conf/@nginx [root@ipython nginx-1.6.1]# cp objs/nginx /software/nginx/sbin/ ####測試新版本的Nginx#### [root@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的配置 測試下訪問### [root@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 ###平滑升級### [root@ipython nginx-1.6.1]# make upgrade ##測試模塊,拒絕1.1.1.30的Nginx請求## ##在http塊里加入以下配置## tcpwrappers on; tcpwrappers_daemon nginx; tcpwrappers_thorough off; ##hosts.deny以下## [root@ipython nginx-1.6.1]# awk '!/^#/' /etc/hosts.deny nginx:1.1.1.30 ##從新讀取Nginx配置文件## [root@ipython nginx-1.6.1]# /software/nginx/sbin/nginx -s reload