Linux下Nginx安全證書ssl配置方法
分享下我是如何一步步在Nginx上配置SSL的。
首先,確保安裝了OpenSSL庫,并且安裝Nginx時使用了–with-http_ssl_module參數(shù)。
初學者或者菜鳥建議使用LNMP進行一鍵安裝。
生成證書:
進入要生成證書的目錄
cd /usr/local/nginx/conf
使用openssl創(chuàng)建創(chuàng)建服務器私鑰,輸入相應提示的信息
openssl genrsa -des3 -out server.key 1024
創(chuàng)建證書簽名請求(Certificate Signing Request (CSR))
openssl req -new -key server.key -out server.csr
清除以SSL啟動Nginx時提示必須輸入密鑰
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
使用剛生成的私鑰和CSR進行證書簽名
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
配置說明:
在server中加入
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
設置 listen 端口為 443,開始測試。
相關文章
Ubuntu上安裝Nginx服務器程序及簡單的環(huán)境配置小結
Nginx是一款高性能的異步非阻塞服務器應用程序,人氣相當高,這里我們就來看一下在Ubuntu上安裝Nginx服務器程序及簡單的環(huán)境配置小結:2016-07-07nginx+lua+redis 灰度發(fā)布實現(xiàn)方案
在微服務化進程中,利用nginx+lua+redis實現(xiàn)灰度發(fā)布至關重要,,通過nginx+lua反向代理,根據(jù)客戶端ip進行路由控制,配合redis存儲允許訪問微服務的ip地址,可以有效地進行用戶分流,感興趣的可以了解一下2024-10-10