北京SEO

linux中编译Nginx支持Tcp_wrappers方法

2019/10/10/17:47:05  阅读:1660  来源:谷歌SEO算法  标签: SEO培训

linux中编译Nginx支持Tcp_wrappers的配置方法不简单,自己测试了很久没有成功,后来看到此文章后得己解决了,下面整理一下与各位参考.

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

1、重新编译Nginx,代码如下:

  1. [root@ipythonnginx-1.6.1]#tarzxf../ngx_tcpwrappers.tar.gz-C./
  2. [root@ipythonnginx-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--phpfensi.com
  3. [root@ipythonnginx-1.6.1]#sed-is'#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. ####不要makeinstall哦,编译好即可####
  5. [root@ipythonnginx-1.6.1]#make

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

  1. ####备份可执行文件,复制新的文件####
  2. [root@ipythonnginx-1.6.1]#mv/software/nginx/sbin/nginx/software/nginx/conf/@nginx
  3. [root@ipythonnginx-1.6.1]#cpobjs/nginx/software/nginx/sbin/
  4. ####测试新版本的Nginx####
  5. [root@ipythonnginx-1.6.1]#/software/nginx/sbin/nginx-t
  6. nginx:theconfigurationfile/software/nginx/conf/nginx.confsyntaxisok
  7. nginx:configurationfile/software/nginx/conf/nginx.conftestissuccessful
  8. ###此时没有加入Tcp_wrappers的配置测试下访问###
  9. [root@ipythonopenssl-1.0.1i]#curl-Ihttp://www.111cn.net
  10. HTTP/1.1200OK
  11. Server:nginx/1.6.1
  12. Date:Mon,11Aug201423:08:08GMT
  13. Content-Type:text/html
  14. Content-Length:612
  15. Last-Modified:Mon,11Aug201422:45:25GMT
  16. Connection:keep-alive
  17. ETag:"53e94785-264"
  18. Accept-Ranges:bytes
  19. ###平滑升级###
  20. [root@ipythonnginx-1.6.1]#makeupgrade
  21. ##测试模块,拒绝1.1.1.30的Nginx请求####在http块里加入如下配置##
  22. tcpwrapperson;
  23. tcpwrappers_daemonnginx;
  24. tcpwrappers_thoroughoff;
  25. ##hosts.deny如下##
  26. [root@ipythonnginx-1.6.1]#awk'!/^#/'/etc/hosts.deny
  27. nginx:1.1.1.30
  28. ##重新读取Nginx配置文件##
  29. [root@ipythonnginx-1.6.1]#/software/nginx/sbin/nginx-sreload
  30. ###此时访问就是403了###
  31. [root@itchenyi~]#curl-Ihttp://www.111cn.net
  32. HTTP/1.1403Forbidden
  33. Server:nginx/1.6.1
  34. Date:Mon,11Aug201423:12:47GMT
  35. Content-Type:text/html
  36. Content-Length:168
  37. 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解析,模块的开发者也未提供详细的使用说明.

广告内容

linux中编译Nginx支持Tcp_wrappers方法 linux中编译Nginx支持Tcp_wrappers方法 linux中编译Nginx支持Tcp_wrappers方法

相关阅读

热门评论

小潘seo 小潘seo

重庆小潘seo博客和你一起学习SEO知识,共同分享SEO优化~

总篇数165

精选文章

RMAN中catalog和nocatalog区别介绍 小技巧:为Linux下的文件分配多个权限 zimbra8.5.1安装第三方签名ssl证书的步骤 解决mysql不能远程连接数据库方法 windows服务器mysql增量备份批处理数据库 mysql中slow query log慢日志查询分析 JavaScript跨域问题总结 Linux下负载均衡软件LVS配置(VS/DR)教程 mysql中权限参数说明 MYSQL(错误1053)无法正常启动

SEO最新算法