前文:因為要用谷歌下的getUserMedia方法,而getUserMedia方法只能在https下才能調用,所以在本地搭建https來測試,現在說說步驟。
步驟1:下載nginx-1.10.3.zip,解壓到F:/
步驟2:在nginx根目錄(F:/nginx-1.10.3/)新建bat文件:
run.bat : nginx.exe
stop.bat : nginx.exe -s stop
reload.bat : nginx.exe -s reload
test.bat:nginx.exe -t
步驟3:進入conf文件夾,新建host和cert兩個文件夾
步驟4:把申請的證書放到cert文件夾(*.crt和*.key)
步驟5:配置服務器,在host文件夾新建hx.conf,內容如下:
server { listen 80; listen chen.caidan.win:443 ssl; server_name chen.caidan.win; ssl_certificate cert/1_chen.caidan.win_bundle.crt; ssl_certificate_key cert/2_chen.caidan.win.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; #proxy_buffering off; location = / { root "E:/ftp/johnChen/chen"; index index.html; } location / { root "E:/ftp/johnChen/chen"; } }
步驟6:進入根目錄下的conf文件夾,打開nginx.conf,在}前輸入include host/*.conf
步驟7:返回到根目錄,雙擊運行test.bat,可以看到下圖配置成功,再運行run.bat,打開地址 https://chen.caidan.win可以訪問。