阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

编译Nginx支持Tcp_wrappers

117次阅读
没有评论

共计 3595 个字符,预计需要花费 9 分钟才能阅读完成。

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

1、重新编译 Nginx

  1. [root@ipython nginx1.6.1]# tar zxf ../ngx_tcpwrappers.tar.gz C ./
  2. [root@ipython nginx1.6.1]#./configure prefix=/software/nginx user=nginx group=nginx withhttp_stub_status_module withhttp_ssl_module withhttp_realip_module withhttp_gzip_static_module withgoogle_perftools_module withdebug httpclientbodytemppath=/var/tmp/nginx/client httpproxytemppath=/var/tmp/nginx/proxy httpfastcgitemppath=/var/tmp/nginx/fastcgi httpuwsgitemppath=/var/tmp/nginx/uwsgi httpscgitemppath=/var/tmp/nginx/scgi withpcre=/root/pcre8.35withopenssl=/root/openssl1.0.1iwithzlib=/root/zlib1.2.8addmodule=./ngx_tcpwrappers
  3. [root@ipython nginx1.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 nginx1.6.1]# make

 

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

  1. #### 备份可执行文件,复制新的文件 ####
  2. [root@ipython nginx1.6.1]# mv /software/nginx/sbin/nginx /software/nginx/conf/@nginx
  3. [root@ipython nginx1.6.1]# cp objs/nginx /software/nginx/sbin/
  4. #### 测试新版本的 Nginx####
  5. [root@ipython nginx1.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 openssl1.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. ContentType: text/html
  14. ContentLength:612
  15. LastModified:Mon,11Aug201422:45:25 GMT
  16. Connection: keepalive
  17. ETag:“53e94785-264”
  18. AcceptRanges: bytes
  19. ### 平滑升级 ###
  20. [root@ipython nginx1.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 nginx1.6.1]# awk ‘!/^#/’/etc/hosts.deny
  27. nginx:1.1.1.30
  28. ## 重新读取 Nginx 配置文件 ##
  29. [root@ipython nginx1.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. ContentType: text/html
  36. ContentLength:168
  37. Connection: keepalive

 

3、Tcp_warppers 模块指令

  1. ###ngx_Tcp_wrappers 配置指令 ###
  2. 1tcpwrappers
  3. 语法 tcpwrappers [on|off]
  4. 默认值 tcpwrappers off
  5. 作用域 http, server, location, limit_except
  6. 描述 模块的开关,开启则使用 TCP Wrappers 进行访问控制,关闭以避免浪费性能
  7. 2tcpwrappers_daemon
  8. 语法 tcpwrappers_daemon name
  9. 默认值 tcpwrappers_daemon nginx
  10. 作用域 http, server, location, limit_except
  11. 描述 该名字的定义用于在 /etc/hosts.[allow|deny]识别
  12. 3tcpwrappers_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 辰逸

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计3595字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中