使用Docker安裝的nginx配置HTTPS證書
阿新 • • 發佈:2018-11-26
新建ssl.conf,將檔案放入conf.d資料夾中
server { listen 443; server_name localhost; ssl on; root html; index index.html index.htm; ssl_certificate cert/1533224843981.pem; ssl_certificate_key cert/1533224843981.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { root html; index index.html index.htm; } }
- 注意點:cert為相對路徑,若是linux資料夾與nginx.conf,若是window則在conf資料夾下。
執行
docker run --name mynginx -p 443:443 -v /opt/data/nginx/nginx.conf:/etc/nginx/nginx.conf -v /opt/data/nginx/conf.d:/etc/nginx/conf.d/default.conf -v /opt/data/nginx/www:/www -v /opt/data/nginx/cert:/etc/nginx/cert -v /opt/data/nginx/ssl.conf:/etc/nginx/conf.d/ssl.conf -d nginx