前段时间研究了一下视频流的简单加密防盗链,参考了很多文章,最后总算搞出来了。现在自己总结了一下。
安装nginx插件
1、下载第三方扩展模块nginx-rtmp-module
sudo git clone https://github.com/arut/nginx-rtmp-module.git
2、下载第三方扩展模块nginx-accesskey-2.0.5,由于没有命令,直接放在了附件,详情看附件
3、解压附件的包
tar -zxvf nginx-accesskey-2.0.5.tar.gz
4、将两个扩展的模块复制到指定位置
这里是将nginx-rtmp-module复制到nginx同一层,nginx-accesskey-2.0.5复制到nginx同目录
5、修改nginx-accesskey-2.0.5里面的配置文件config,主要是确认HTTP_MODULES和ngx_module_name的值
#修改$HTTP_ACCESSKEY_MODULE为ngx_http_accesskey_module
USE_MD5=YES
USE_SHA1=YES
ngx_addon_name=ngx_http_accesskey_module
HTTP_MODULES="$HTTP_MODULES ngx_http_accesskey_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_accesskey_module.c"
if [ "$ngx_module_link" = DYNAMIC ] ; then
ngx_module_type=HTTP
ngx_module_name=ngx_http_accesskey_module
ngx_module_srcs="$ngx_addon_dir/ngx_http_accesskey_module.c"
. auto/module
fi
6、到nginx目录下执行命令添加组件
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-stream=dynamic --with-stream_ssl_module --add-module=./nginx-accesskey-2.0.5 --add-module=../nginx-rtmp-module/
如果命令执行失败,提示
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= path option.
大概意思是:HTTP重写模块需要PCRE库。您可以使用–without-http_rewrite_module禁用模块选项,或将PCRE库安装到系统中,或构建PCRE库通过使用–with-pcre = path 选项从源与nginx静态。
解决办法:
需要安装一下两个库文件:(nginx pcre 安装)
sudo apt-get install libpcre3 libpcre3-dev
apt-get install openssl libssl-dev
apt-get install git
理论上是没有问题的,等待执行完成就行
8、等执行完成后,同目录下,输入命令编译
make
等待执行完成
9、执行完成后,到编译后的目录进行查看,编译后的目录一般在
进入里面查看配置信息是否成功,注意-V是大写的V,如果看到nginx-accesskey-2.0.5和nginx-rtmp-module表示成功
[root@localhost sbin]# pwd
/usr/local/nginx/sbin
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.20.2
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
built with OpenSSL 1.1.1k FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-stream=dynamic --with-stream_ssl_module --add-module=./nginx-accesskey-2.0.5 --add-module=../nginx-rtmp-module/
[root@localhost sbin]#
至此,插件部分安装完成