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

目录
相关文章
|
10天前
|
应用服务中间件 Linux 网络安全
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
14 0
|
5月前
|
应用服务中间件 Linux 网络安全
suse 12 编译部署 Nginx
suse 12 编译部署 Nginx
76 0
|
Web App开发 Rust 应用服务中间件
在Nginx当中支持QUIC协议
Quick UDP Internet Connection(QUIC)协议是Google公司提出的基于UDP的高效可靠协议。有关协议的主要内容就不在本文过多描述了,本文主要是来讲一下,在Nginx当中如何去支持QUIC协议。 由于个人水平有限,如果哪里写的不对的地方,还请各位大佬们指正。
1560 0
在Nginx当中支持QUIC协议
|
JavaScript 应用服务中间件 nginx
Nginx - 同一域名配置多个 Vue 项目(支持Webpack、Uniapp)
Nginx - 同一域名配置多个 Vue 项目(支持Webpack、Uniapp)
743 0
Nginx - 同一域名配置多个 Vue 项目(支持Webpack、Uniapp)
|
应用服务中间件 网络安全 nginx
Nginx配置WebSocket 【支持wss与ws连接】
Nginx配置WebSocket 【支持wss与ws连接】
4880 0
|
8月前
|
应用服务中间件 nginx
编译nginx常见错误
编译nginx常见错误
|
4月前
|
应用服务中间件 Linux Shell
centos编译安装nginx(2)
安装成功之后,nginx的配置文件,在安装目录(/usr/local/nginx)下的conf目录下的nginx.conf中。 Php-fpm在安装的时候已经配置过了,这里不再赘述
56 0
centos编译安装nginx(2)
|
4月前
|
应用服务中间件 Shell Linux
centos编译安装nginx(1)
进入解压后的目录,编译
108 0
|
5月前
|
Kubernetes 应用服务中间件 Linux
suse 12 编译部署Keepalived + nginx 为 kube-apiserver 提供高可用
suse 12 编译部署Keepalived + nginx 为 kube-apiserver 提供高可用
54 0
|
6月前
|
移动开发 网络协议 应用服务中间件
70分布式电商项目 - nginx编译参数详解
70分布式电商项目 - nginx编译参数详解
26 0