CentOS7

動画視聴認証設定

nginx暗号化通信有効化

[root@centos ~]# systemctl stop nginx ← nginx停止
[root@centos ~]# wget https://nginx.org/download/nginx-1.17.3.tar.gz ← nginxダウンロード
※最新版のダウンロードページURL
[root@centos ~]# tar zxf nginx-*.tar.gz ← nginx展開
[root@centos ~]# cd nginx-* ← nginx展開先ディレクトリへ移動
[root@centos nginx-1.17.3]# git clone https://github.com/arut/nginx-rtmp-module.git ← nginx-rtmp-moduleダウンロード
[root@centos nginx-1.17.3]# ./configure --add-module=nginx-rtmp-module/ --with-http_ssl_module --with-debug && make && make install ← nginx+nginx-rtmp-moduleインストール
[root@centos nginx-1.17.3]# cd ← nginx展開先ディレクトリを抜ける
[root@centos ~]# rm -rf nginx-* ← nginx展開先ディレクトリとダウンロードしたファイルを削除
[root@centos ~]# systemctl start nginx ← nginx起動

nginx設定

  1. サーバー証明書取得
    暗号化通信するためサーバー証明書を取得する。

    Webサーバー間通信内容暗号化(Apache+mod_SSL+Certbot)を実施
    • Certbotクライアントインストール
    • サーバー証明書取得
    • サーバー証明書自動更新設定
  2. nginx設定
    [root@centos ~]# vi /usr/local/nginx/conf/nginx.conf ← 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;
        #    }
        }
        暗号化通信設定追加(ここまで)
        動画視聴認証設定追加(ここまで)
        動画ファイルの直接再生禁止設定追加(ここまで)
    [root@centos ~]# systemctl restart nginx ← nginx再起動
  3. ポートTCP443番のOPEN
    ルーター側の設定でポートTCP443番をOPENする。
    ※ルーターの設定は各ルーターのマニュアルまたはメーカー別ルーターポート開放手順を参照
  4. 認証用ユーザー名/パスワード登録
    [root@centos ~]# mkdir /usr/local/nginx/passwd/ ← ユーザー名/パスワードファイル作成先ディレクトリ作成
    [root@centos ~]# yum -y install httpd-tools ← httpd-toolsインストール
    [root@centos ~]# htpasswd -b -c -m /usr/local/nginx/passwd/.htpasswd ユーザー名 パスワード ← ユーザー名/パスワード登録
    Adding password for user xxxxxxxx

オンデマンド配信動画視聴認証確認

ライブ配信動画視聴認証確認


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2020-10-11 (日) 11:06:29