關於 SSL 的產生、建立、移除密碼... 等等,請見下述兩篇文章:
此篇假設已經將 SSL Key 產生完畢,在此只有 Nginx SSL 的設定檔範例。
Nginx 的 SSL 設定檔範例
- SSL Key 的路徑:/etc/nginx/ssl.crt/
Nginx 設定 SSL 的設定檔範例如下:(/etc/nginx/sites-enabled/example.conf)
server { listen 443; server_name example.com.tw root /var/www/; index index.html index.htm; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log crit; # 重點是下述三行 ssl on; ssl_certificate /etc/nginx/ssl.crt/ssl-bundle.crt; ssl_certificate_key /etc/nginx/ssl.crt/ssl.example.com-nopass.key; # 以下可以省略,但是還是建議加上(最下方有連結說明移除 SSLv2, SSLv3) ssl_session_timeout 5m; ssl_session_cache shared:SSL:5m; #ssl_protocols SSLv3 TLSv1; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA; ssl_prefer_server_ciphers on; }