1. 建立key
openssl genrsa -des3 -out server.key 2048
輸入密碼即可。
2. 建立 csr
openssl req -new -key engir.key -out server.csr
按流程填寫,如
Country Name (2 letter code) [GB]: JP
State or Province Name (full name) [Berkshire]:Tokyo
Locality Name (eg, city) [Newbury]:Bunkyo-ku
Organization Name (eg, company) [My Company Ltd]: HuaWei
Organizational Unit Name (eg, section) :ENGR
Common Name (eg, your name or your server's hostname) []:abc.com
Email Address []:info@it.co.jp 注意郵件地址要和註冊網域名稱時的郵件地址一樣
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: 斷行符號
An optional company name []: 斷行符號
3. 通過 server.key server.csr 在相應的網站申請 認證
如: http://www.startssl.com/
http://ocsp.godaddy.com/
申請成功後會得到兩個檔案:
gd_bundle.crt abc.com.crt
4. 設定nginx的配置
上傳 gd_bundle.crt abc.com.crt 檔案至 nginx的配置目錄下 /usr/local/nginx/conf
執行
cat abc.com.crt gd_bundle.crt > abc.com.chained.crt
Nginx的配置如下:
server {
listen 443;
server_name ttt.e.com;
ssl on;
ssl_certificate /usr/local/nginx/conf/abc.com.chained.crt;
ssl_certificate_key /usr/local/nginx/conf/abc.com.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
root html;
index index.php;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
fastcgi_param HTTPS on;
include fastcgi.conf;
}
}
5. 驗證
執行
openssl s_client -connect www.godaddy.com:443
最後訪問 https://abc.com 如果能看到認證的資訊,而且串連都正常就OK了。
注意:
安裝nginx 時要加上https模組,編譯時間:
./configure --with-http_sub_module --with-http_ssl_module
可以用 /usr/local/nginx/sbin/nginx -V 來查看。