天天看点

CentOS 7 下 NGINX 增加 nginx-module-vts 模块

文章目录

      • CentOS 7 下 NGINX 增加 nginx-module-vts 模块
          • 编译依赖安装
          • nginx 下载
          • nginx-module-vts 下载
          • 解压 nginx
          • 预编译
          • 编译 && 安装
          • 验证可用模块
          • OpenSSL 生成加密文件
          • nginx.conf 配置
          • 启动 NGINX
          • 浏览器验证
      • 参考

CentOS 7 下 NGINX 增加 nginx-module-vts 模块

编译依赖安装
nginx 下载
nginx-module-vts 下载
解压 nginx
预编译
编译 && 安装
验证可用模块
[[email protected] ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
configure arguments: --prefix=/usr/local/nginx --add-module=../nginx-module-vts
           
OpenSSL 生成加密文件
# 方法一 -- 面交互方式
[[email protected] ~]# printf "vts_user:$(openssl passwd -crypt 1234567890)\n" > /usr/local/nginx/conf/nginx_vts.db

# 方法二 -- 交互方式
[[email protected] ~]# htpasswd -cm ./nginx_vts.db vts_user
New password: 
Re-type new password: 
Adding password for user vts_user
           
nginx.conf 配置
http {
    include       mime.types;
    default_type  application/octet-stream;

	# 配置 vts 使用
    vhost_traffic_status_zone;
    
	server {
        listen       80;
        server_name  localhost;
        
        location / {
            root   html;
            index  index.html index.htm;

            # auth Setting
            auth_basic  "Add Auth For VTS";
            auth_basic_user_file /usr/local/nginx/conf/nginx_vts.db;
        }

        location /vts {

            # vhost Setting
            vhost_traffic_status_display;
            vhost_traffic_status_display_format html;
        }
        
	}
	
}
           
# NGINX 出现 403 Forbidden 问题
	- 站点目录没有 NGINX 用户的访问权限
	- 配置文件里没有配置默认首页参数(index.html)
	- 配置文件里有配置默认首页参数,但站点目录下没有指定参数文件
	- 配置文件里设置了 allow、deny 等权限控制,导致客户端没有访问权限
           
启动 NGINX
浏览器验证
CentOS 7 下 NGINX 增加 nginx-module-vts 模块
CentOS 7 下 NGINX 增加 nginx-module-vts 模块
CentOS 7 下 NGINX 增加 nginx-module-vts 模块

参考

  • Nginx模块系列之auth_basic模块
  • openssl passwd 使用
  • 访问 NGINX 出现 403 Forbidden 原因

继续阅读