[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起動 |
[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再起動 |
[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 |