1. 程式人生 > >nginx ssl配置步驟

nginx ssl配置步驟

書簽 conf 編譯 onf 步驟 list serve -o pre

1、nginx編譯時加ssl模塊(加參數--with-http_ssl_module):
./configure --prefix=/usr/local/nginx --with-http_ssl_module

2、生成私鑰(key),csr(證書簽名請求文件),CA證書(crt)

生成key:
openssl genrsa -des3 -out server.key 1024
生成csr:
openssl req -new -key server.key -out server.csr
生成證書:
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

使用私鑰生成解密後的key,達到免密碼重啟nginx的效果
openssl rsa -in server.key -out npserver.key

3、最後配置nginx.conf

server {
listen 443 ssl;
ssl on;
server_name dbserver;

                    ssl_certificate    ssl/server.crt;
                    ssl_certificate_key    ssl/npserver.key;

                    location  /  {
                       root   html;
                         index  443.html;
                    }

}

nginx ssl配置步驟