- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-10-11T10:55:11+09:00","default:egashira","egashira")
#author("2020-10-11T11:06:29+09:00","default:egashira","egashira")
[[CentOS7]]
*動画視聴認証設定 [#icf5981c]
**nginx暗号化通信有効化 [#me4426ea]
|BGCOLOR(black):COLOR(white):|c
|[root@centos ~]# systemctl stop nginx &color(lime){← nginx停止};|
|[root@centos ~]# wget https://nginx.org/download/nginx-1.17.3.tar.gz &color(lime){← nginxダウンロード};|
|※最新版の[[ダウンロードページ>https://nginx.org/en/download.html]]URL|
|[root@centos ~]# tar zxf nginx-*.tar.gz &color(lime){← nginx展開};|
|[root@centos ~]# cd nginx-* &color(lime){← nginx展開先ディレクトリへ移動};|
|[root@centos nginx-1.17.3]# git clone https://github.com/arut/nginx-rtmp-module.git &color(lime){← nginx-rtmp-moduleダウンロード};|
|[root@centos nginx-1.17.3]# ./configure --add-module=nginx-rtmp-module/ --with-http_ssl_module --with-debug && make && make install &color(lime){← nginx+nginx-rtmp-moduleインストール};|
|[root@centos nginx-1.17.3]# cd &color(lime){← nginx展開先ディレクトリを抜ける};|
|[root@centos ~]# rm -rf nginx-* &color(lime){← nginx展開先ディレクトリとダウンロードしたファイルを削除};|
|[root@centos ~]# systemctl start nginx &color(lime){← nginx起動};|
**nginx設定 [#b29979fc]
+サーバー証明書取得&br;暗号化通信するためサーバー証明書を取得する。&br;&br;Webサーバー間通信内容暗号化(Apache+mod_SSL+Certbot)を実施
+サーバー証明書取得&br;暗号化通信するためサーバー証明書を取得する。&br;&br;[[Webサーバー間通信内容暗号化(Apache+mod_SSL+Certbot)]]を実施
--Certbotクライアントインストール
--■サーバー証明書取得
--■サーバー証明書自動更新設定
--サーバー証明書取得
--サーバー証明書自動更新設定
+nginx設定
|BGCOLOR(black):COLOR(white):|c
|[root@centos ~]# vi /usr/local/nginx/conf/nginx.conf &color(lime){← nginx設定ファイル編集};|
server {
listen 80;
server_name localhost;
httpからhttpsへの自動リダイレクト設定追加(ここから)
# httpをhttpsへリダイレクト
if ($request_uri !~ /on_play) {
return 301 https://$host:443$request_uri;
}
httpからhttpsへの自動リダイレクト設定追加(ここまで)
・
・
・
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
暗号化通信設定追加(ここから)
動画視聴認証設定追加(ここから)
動画ファイルの直接再生禁止設定追加(ここから)
# HTTPS server
#
server {
listen 443 ssl; ← HTTPSポート変更
server_name localhost;
ssl_certificate /etc/letsencrypt/live/server.com/fullchain.pem; ← サーバー証明書と中 間証明書
ssl_certificate_key /etc/letsencrypt/live/server.com/privkey.pem; ← 秘密鍵
# faviconが存在しない旨のログを出力しないようにする
location /favicon {
empty_gif;
access_log off;
log_not_found off;
}
# 動画視聴認証設定
location / {
satisfy any;
allow 192.168.1.0/24; # 192.168.1.0/24からのみ認証なしでアクセスを許可
deny all;
auth_basic "STREAMING PAGE";
auth_basic_user_file "/usr/local/nginx/passwd/.htpasswd";
}
# 動画ファイルの直接再生禁止設定
location /vod/ {
valid_referers server_names server.com;
if ($invalid_referer) { return 403; }
}
location /live/ {
valid_referers server_names server.com;
if ($invalid_referer) { return 403; }
}
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
ssl_ciphers ECDH:!aNULL:!eNULL:!SSLv2:!SSLv3;
ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
}
暗号化通信設定追加(ここまで)
動画視聴認証設定追加(ここまで)
動画ファイルの直接再生禁止設定追加(ここまで)
|BGCOLOR(black):COLOR(white):|c
|[root@centos ~]# systemctl restart nginx &color(lime){← nginx再起動};|
+ポートTCP443番のOPEN&br;ルーター側の設定でポートTCP443番をOPENする。&br;※ルーターの設定は各ルーターのマニュアルまたはメーカー別ルーターポート開放手順を参照
+認証用ユーザー名/パスワード登録
|BGCOLOR(black):COLOR(white):|c
|[root@centos ~]# mkdir /usr/local/nginx/passwd/ &color(lime){← ユーザー名/パスワードファイル作成先ディレクトリ作成};|
|[root@centos ~]# yum -y install httpd-tools &color(lime){← httpd-toolsインストール};|
|[root@centos ~]# htpasswd -b -c -m /usr/local/nginx/passwd/.htpasswd &color(lime){ユーザー名 パスワード ← ユーザー名/パスワード登録};|
|Adding password for user xxxxxxxx|
**オンデマンド配信動画視聴認証確認 [#d2bdc340]
-内部のPCブラウザからhttps://サーバー名/vod.htmlへアクセスして認証なしで動画が視聴できること
-外部のPCブラウザからhttps://サーバー名/vod.htmlへアクセスしてユーザー名/パスワード入力後、動画が視聴できること
-内部のiPhoneまたはiPadからhttps://サーバー名/vod.htmlへアクセスして認証なしで動画が視聴できること
-外部のiPhoneまたはiPadからhttps://サーバー名/vod.htmlへアクセスしてユーザー名/パスワード入力後、動画が視聴できること
-VLC media playerを起動して「メディア」-「ネットワークストリームを開く」で「ネットワークURL」にhttps://RTMPサーバー名:443/アプリケーション名/動画ファイル名.m3u8(例:https://server.com/vod/test.m3u8)を入力して「再生」ボタン押下で動画が再生されないこと
**ライブ配信動画視聴認証確認 [#ee7265b9]
-内部のPCブラウザからhttps://サーバー名/live.htmlへアクセスして認証なしでカメラ映像・音声が視聴できること
-外部のPCブラウザからhttps://サーバー名/live.htmlへアクセスしてユーザー名/パスワード入力後、カメラ映像・音声が視聴できること
-内部のiPhoneまたはiPadからhttps://サーバー名/live.htmlへアクセスして認証なしでカメラ映像・音声が視聴できること
-外部のiPhoneまたはiPadからhttps://サーバー名/live.htmlへアクセスしてユーザー名/パスワード入力後、カメラ映像・音声が視聴できること
-VLC media playerを起動して「メディア」-「ネットワークストリームを開く」で「ネットワークURL」にhttps://RTMPサーバー名:443/アプリケーション名/ストリームキー.m3u8(例:https://server.com/live/live.m3u8)を入力して「再生」ボタン押下で動画が再生されないこと