搜尋
首頁運維Nginxnginx如何設定ssl雙向驗證

nginx如何設定ssl雙向驗證

May 15, 2023 am 11:58 AM
nginxssl

1、安裝nginx略

#2、使用openssl實作憑證中心
由於是使用openssl架設私有憑證中心,因此要確保以下欄位在憑證中心的憑證、服務端憑證、客戶端憑證中都相同
country name
state or province name
locality name
organization name
organizational unit name

編輯憑證中心設定檔
vim /etc/pki/tls/openssl.cnf

[ ca_default ]
dir             = /etc/pki/ca
certs           = $dir/certs            # where the issued certs are kept
crl_dir       an = $dir/cept
crl_dir       問題 = $dir/crl>p. base        = $dir/index.txt        # database index file.
# unique_subject = no                    # set to 'no' to allow creation of
           with same subject.
new_certs_dir   = $dir/newcerts         # default place for new certs.
certificate     = $dir/cacert.pem # the ca certificate
serial          = $dir/serial           # the current serial number
crlnumber      = $dir/crlnlnumber                           # must be commented out to leave a v1 crl
crl         crl.pem          # the current crl
private_key     = $dir/private/cakey.pem# the private key
randfile       = $$ir/private .##randfile    _name ]

countryname                     = country name(2 letter code)

countryname_default                          = 2
stateorprovincename             = state or province name (full name)
stateorprovincename_default state or province name (full name)
stateorprovincename_default  ##localityname                    = locality name (eg, city)
localityname_default           = fz name_default name name   any)
0.organizationname_default      = zdz
organizationalunitname          = organizational unit name (eg, section)
organizationalunitname_default  = zdz

建立憑證私鑰
cd /etc/pki/ca/private
(umask 077;openssl genrsa -out cakey.pem 2048)
產生自簽證書

cd /etc/pki/ca/

openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days=3655


#3、建立伺服器憑證

mkdir /usr/local/nginx/ssl

#cd /usr/local/nginx/ssl

(umask 077;openssl genrsa -out nginx.key 1024)openssl req -new -key nginx.key -out nginx.csr
openssl ca -in nginx.csr -out nginx.crt -days=3650


#4、建立用戶端瀏覽器憑證

(umask 077;openssl genrsa -out client.key 1024)

openssl req -new -key client.key -out client.csr

openssl ca -in client.csr -out client.crt -days=3650將文字格式的憑證轉換成可以匯入瀏覽器的憑證
openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12  

5、設定nginx伺服器驗證
vim /usr/local/nginx/conf/nginx.conf
ssl on;
ssl_certificate         /usr/local/nginx/ssl/ nginx.crt;
ssl_certificate_key     /usr/local/nginx/ssl/nginx.key;
ssl_client_certificate  /usr/local/nginx/ssl/cacert.pemm;#ssl_ )  on ;                                         伺服器為使用者端時不開啟,並於沒有憑證的客戶」


點選「新增例外」
nginx如何設定ssl雙向驗證
點選「確認安全例外」
nginx如何設定ssl雙向驗證

nginx如何設定ssl雙向驗證6、設定雙向驗證

nginx設定開啟ssl_verify_client       on;    nginx如何設定ssl雙向驗證在用戶端瀏覽器沒有安裝憑證的情況下存取


在用戶端瀏覽器匯入憑證

#將在linux伺服器上產生的用戶端憑證下載到windows上

nginx如何設定ssl雙向驗證
開啟火狐瀏覽器的進階標籤
nginx如何設定ssl雙向驗證
在憑證管理員中的您的憑證中點選匯入
nginx如何設定ssl雙向驗證
選擇憑證並匯入
nginx如何設定ssl雙向驗證
再次刷新網頁,彈出「使用確認」點擊確定,就實現了雙向驗證

以上是nginx如何設定ssl雙向驗證的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文轉載於:亿速云。如有侵權,請聯絡admin@php.cn刪除
NGINX與Apache:比較Web服務器技術NGINX與Apache:比較Web服務器技術May 02, 2025 am 12:08 AM

NGINX適合處理高並發和靜態內容,Apache適用於動態內容和復雜URL重寫。 1.NGINX採用事件驅動模型,適合高並發。 2.Apache使用進程或線程模型,適用於動態內容。 3.NGINX配置簡單,Apache配置複雜但更靈活。

nginx和apache:部署和配置nginx和apache:部署和配置May 01, 2025 am 12:08 AM

NGINX和Apache各有優勢,選擇取決於具體需求。 1.NGINX適合高並發,部署簡單,配置示例包括虛擬主機和反向代理。 2.Apache適用於復雜配置,部署同樣簡單,配置示例包括虛擬主機和URL重寫。

NGINX單元的目的:運行Web應用程序NGINX單元的目的:運行Web應用程序Apr 30, 2025 am 12:06 AM

NGINXUnit的目的是簡化Web應用程序的部署和管理。其優勢包括:1)支持多種編程語言,如Python、PHP、Go、Java和Node.js;2)提供動態配置和自動重載功能;3)通過統一的API管理應用生命週期;4)採用異步I/O模型,支持高並發和負載均衡。

NGINX:高性能Web服務器的簡介NGINX:高性能Web服務器的簡介Apr 29, 2025 am 12:02 AM

NGINX始於2002年,由IgorSysoev開發,旨在解決C10k問題。 1.NGINX是高性能Web服務器,基於事件驅動的異步架構,適用於高並發。 2.提供反向代理、負載均衡和緩存等高級功能,提升系統性能和可靠性。 3.優化技巧包括調整worker進程數、啟用Gzip壓縮、使用HTTP/2和安全配置。

Nginx vs. Apache:看他們的架構Nginx vs. Apache:看他們的架構Apr 28, 2025 am 12:13 AM

NGINX和Apache在架構上的主要區別在於:NGINX採用事件驅動、異步非阻塞模型,而Apache使用進程或線程模型。 1)NGINX通過事件循環和I/O多路復用機制高效處理高並發連接,適合靜態內容和反向代理。 2)Apache採用多進程或多線程模型,穩定性高但資源消耗大,適合需要豐富模塊擴展的場景。

NGINX與Apache:檢查優點和缺點NGINX與Apache:檢查優點和缺點Apr 27, 2025 am 12:05 AM

NGINX適合處理高並發和靜態內容,Apache則適用於復雜配置和動態內容。 1.NGINX高效處理並發連接,適合高流量場景,但處理動態內容需額外配置。 2.Apache提供豐富模塊和靈活配置,適合複雜需求,但高並發性能較差。

nginx和apache:了解關鍵差異nginx和apache:了解關鍵差異Apr 26, 2025 am 12:01 AM

NGINX和Apache各有優劣,選擇應基於具體需求。 1.NGINX適合高並發場景,因其異步非阻塞架構。 2.Apache適用於需要復雜配置的低並發場景,因其模塊化設計。

NGINX單元:關鍵功能NGINX單元:關鍵功能Apr 25, 2025 am 12:17 AM

NGINXUnit是一個開源應用服務器,支持多種編程語言,提供動態配置、零停機更新和內置負載均衡等功能。 1.動態配置:無需重啟即可修改配置。 2.多語言支持:兼容Python、Go、Java、PHP等。 3.零停機更新:支持不中斷服務的應用更新。 4.內置負載均衡:可將請求分發到多個應用實例。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具