文章目录
CentOS 7 下 NGINX 增加 nginx-module-vts 模块
编译依赖安装
[root@lsr ~]# yum -y isntall zlib zlib-devel pcre pcre-devel openssl openssl-devel
nginx 下载
[root@lsr soft]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
nginx-module-vts 下载
[root@lsr soft]# git clone git://github.com/vozlt/nginx-module-vts.git
解压 nginx
[root@lsr soft]# tar zxf nginx-1.18.0.tar.gz
预编译
[root@lsr nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --add-module=../nginx-module-vts
编译 && 安装
[root@lsr nginx-1.18.0]# make -j 4 && make -j 4 install
验证可用模块
[root@lsr ~]# /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 生成加密文件
# 方法一 -- 面交互方式
[root@lsr ~]# printf "vts_user:$(openssl passwd -crypt 1234567890)\n" > /usr/local/nginx/conf/nginx_vts.db
# 方法二 -- 交互方式
[root@lsr ~]# 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
[root@lsr conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
浏览器验证