A. 如何在Nginx中添加SSL證書以支持HTTPS協議訪問
獲得Nginx環境SSL證書
安裝流程:
環境檢測,檢測命令如下(測試nginx是否支持SSL)nginx-V
如果有輸入 –with-http_ssl_mole 表示已編譯openssl,支持安裝ssl
如果沒有安裝請下載nginx源碼重新編譯:./configure--with-http_stub_status_mole--with-http_ssl_mole
make&&makeinstall
配置Nginx
server{
listen80;
listen443ssl;
server_namewww.gworg.cn;
ssl_protocolsTLSv1.2TLSv1.1TLSv1;
ssl_certificate/etc/ssl/yourdomain.com.crt;
ssl_certificate_key/etc/ssl/yourdomain.com.key;
ssl_prefer_server_cipherson;
#自動跳轉到HTTPS(可選)
if($server_port=80){
rewrite^(.*)$https://$host$1permanent;
}
location/{
root/home/web/;
indexindex.php;
}
}
以上配置僅供參考,其他參數請根據生產環境需要添加。
安裝後重啟nginx使其生
解決辦法:SSL證書可以在Gworg申請,然後根據以上文檔安裝,Nginx證書分為:crt公鑰與key私鑰2個文件。
B. nginx能配置多個ssl證書嗎
nginx支持TLS協議的SNI擴展(Server Name Indication,簡單地說這個擴展使得在同一個IP上可以以不同的證書serv不同的域名)。不過,SNI擴展還必須有客戶端的支持,另外本地的OpenSSL必須支持它。
如果啟用了SSL支持,nginx便會自動識別OpenSSL並啟用SNI。是否啟用SNI支持,是在編譯時由當時的 ssl.h 決定的(SSL_CTRL_SET_TLSEXT_HOSTNAME),如果編譯時使用的OpenSSL庫支持SNI,則目標系統的OpenSSL庫只要支持它就可以正常使用SNI了。
nginx在默認情況下是TLS SNI support disabled。
啟用方法:
需要重新編譯nginx並啟用TLS。步驟如下:
# wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz
# tar zxvf openssl-1.0.1e.tar.gz
# ./configure --prefix=/usr/local/nginx --with-http_ssl_mole \
--with-openssl=./openssl-1.0.1e \
--with-openssl-opt="enable-tlsext"
# make
# make install
查看是否啟用:
# /usr/local/nginx/sbin/nginx -V
TLS SNI support enabled
這樣就可以在 同一個IP上配置多個HTTPS主機了。
C. Nginx如何安裝安信SSL證書
第一步:申請並獲取證書
在安信SSL平台申請購買SSL證書,成功之後,伺服器SSL證書由系統通過 Email 方式發送給用戶,證書文件的內容格式如下,請把您的 SSL證書內容(包括「—–BEGIN CERTIFICATE—–」和「—–END CERTIFICATE—–」)粘貼到記事本等文本編輯器中,在伺服器證書代碼文本結尾處回車換行,並分別粘貼證書鏈代碼(包括「—–BEGIN CERTIFICATE—–」和「—–END CERTIFICATE—–」),修改文件擴展名,保存包含證書和證書鏈代碼的文本文件為 server.pem 或者 server.crt 文件。
第二步:修改配置文件
最後把 server.crt(或者 server.pem) 、server.key(生成 csr 時生成的私鑰)兩個文件保存到同一個目錄,例如/usr/local/nginx/conf 目錄下。
1.用文本編輯器打開 Nginx 根目錄下 conf/nginx.conf 文件找到並更新一下內容:
server
{
listen 443 ssl;
ssl_certificate /usr/local/nginx/conf/server.crt; #(備註:證書路徑)
ssl_certificate_key /usr/local/nginx/conf/server.key; #(備註:私鑰路徑)
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root /home/wwwroot/www.domain.com; #(備註:網站文件路徑) index index.php index.html index.htm; #(備註:默認首頁文件指定)
}
#Blow,I can』t anyway update.
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name _;
index index.html index.htm index.php;
root /home/wwwroot/default;
第三步:https 訪問排錯調整設置:
如果控制每個網站對應的文件路徑有單獨的配置文件,一般放在/usr/local/nginx/conf/vhost 下面。需要編輯對應網站配置文件配置 443 埠,不然可能導致 http 能正常訪問,https 訪問 404 報錯。修改規則參考如下:
server
{
listen 80; #啟用 80
listen 443 ssl; #404 報錯就是需要在這里啟用 443
#listen [::]:80;
server_name www.domain.com domain.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/www.domain.com;
include rewrite/opencart.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*.php$ { deny all; }
include enable-php.conf;
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*.(js|css)?$
{
expires 12h;
}
location ~ /.well-known{ allow all;
}
location ~ /.
{
deny all;
}
location / {
if ($host != 『www.domain.com』) {
rewrite ^/(.*)$ https://www.domain.com/$1 permanent;
#設置重定向自動跳轉到 www 網站。
}
try_files $uri @opencart;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location /admin/ { index index.php;
}
location ~* (.(tpl|ini))$ { deny all;
}
access_log /home/wwwlogs/domain.log;
}
修改保存重啟 nginx 服務:
service nginx restart
完成以上步驟,即可安裝成功。
D. 在nginx上面配置了ssl證書,用來https訪問,但是內網可以訪問,外網不能訪問
這還是配置ssl證書出了點問題吧。在Nginx上安裝ssl證書的步驟參考網頁鏈接,你看看哪裡不對。如果是在GDCA申請ssl證書,可以叫他們技術人員幫忙安裝配置,以免出現問題。
E. Linux+Nginx下SSL證書安裝
"一.Nginx安裝SSL證書需要兩個配置文件
(溫馨提示:安裝證書前請先備份您需要修改的伺服器配置文件)
1_root_bundle.crt、2_domainname.com.key。註:這三個證書文件都在文件夾for Nginx.zip中,例:1_root_bundle.crt是根證書鏈(公鑰),2_domainname.com.key為私鑰。
(其中:證書公鑰、私鑰文件一般以您的域名命名;證書後綴名crt和cer的性質是一樣的)。
二.Nginx安裝證書
1.打開Nginx安裝目錄下conf目錄中的nginx.conf文件
找到:
#HTTPS server
#
#server{
#listen 443;
#server_name localhost;
#ssl on;
#ssl_certificate cert.pem;
#ssl_certificate_key cert.key;
#ssl_session_timeout 5m;
#ssl_protocols SSLv2 SSLv3 TLSv1;
#ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
#ssl_prefer_server_ciphers on;
#location/{
#root html;
#index index.html index.htm;
#}
#}
將其修改為:
server{
listen 443;
server_name localhost;
ssl on;
ssl_certificate 1_root_bundle.crt;(證書公鑰)
ssl_certificate_key 2_domainname.com.key;(證書私鑰)
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
ssl_prefer_server_ciphers on;
location/{
root html;
index index.html index.htm;
}
註:配置完成後的網站路徑及默認頁等配置請與80埠保持一致。
2. 本地測試訪問。
如果本地測試,請做本地解析訪問:打開系統盤:\Windows\System32\Drivers\etc\hosts文件,用文本編輯器修改,把證書綁定的域名解析到本地ip。
3.完成配置後的效果。
啟動nginx,訪問https://+證書綁定的域名
註:部署完畢後若網站無法通過https正常訪問,可確認伺服器443埠是否開啟或被網站衛士等加速工具攔截。
(1)開啟方法:防火牆設置-例外埠-添加443埠(TCP)。
(2)若被安全或加速工具攔截,可以在攔截記錄中將443添加至信任列表。
重啟後,重新通過https訪問。
三.SSL證書的備份
請保存好收到的證書壓縮包文件及密碼,以防丟失。以上內容來自景安網路。
"
F. 怎麼驗證nginx配置域名ssl證書成功
HTTPS網站可以正常打開,那麼說明配置成功了。
G. 如何在nginx伺服器部署ssl證書
Nginx伺服器部署ssl證書的指南網頁鏈接,寫得很詳細。如果是在GDCA申請的SSL證書,他們可以免費幫安裝。
H. linux nginx ssl證書怎麼配置
Nginx安裝SSL證書:抄https://www.gworg.com/ssl/107.html
Nginx 自動跳轉到HTTPS:https://www.gworg.com/ssl/167.html
注意襲:安裝防火牆需要設置允許443埠或關閉防火牆,如果本地伺服器安裝安全狗的,請允許443埠。SSL證書需要淘寶Gworg獲取。
I. 如何創建ssl證書 nginx
你可以到CA機構申請SSL證書,然後安裝Nginx的配置教程配置SSL即可。優質證書推薦wosign.com/price.htm