最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

nginx代理服務(wù)器配置雙向證書驗(yàn)證的方法

 更新時(shí)間:2019年02月13日 11:46:52   作者:李毅  
今天小編就為大家分享一篇關(guān)于nginx代理服務(wù)器配置雙向證書驗(yàn)證的方法,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧

生成證書鏈

用腳本生成一個(gè)根證書, 一個(gè)中間證書(intermediate), 三個(gè)客戶端證書.

中間證書的域名為 localhost.

#!/bin/bash -x
set -e
for C in `echo root-ca intermediate`; do
 mkdir $C
 cd $C
 mkdir certs crl newcerts private
 cd ..
 echo 1000 > $C/serial
 touch $C/index.txt $C/index.txt.attr
 echo '
[ ca ]
default_ca = CA_default
[ CA_default ]
dir      = '$C'  # Where everything is kept
certs     = $dir/certs        # Where the issued certs are kept
crl_dir    = $dir/crl        # Where the issued crl are kept
database    = $dir/index.txt      # database index file.
new_certs_dir = $dir/newcerts      # default place for new certs.
certificate  = $dir/cacert.pem        # The CA certificate
serial     = $dir/serial        # The current serial number
crl      = $dir/crl.pem        # The current CRL
private_key  = $dir/private/ca.key.pem    # The private key
RANDFILE    = $dir/.rnd   # private random number file
nameopt    = default_ca
certopt    = default_ca
policy     = policy_match
default_days  = 365
default_md   = sha256
[ policy_match ]
countryName      = optional
stateOrProvinceName  = optional
organizationName    = optional
organizationalUnitName = optional
commonName       = supplied
emailAddress      = optional
[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name
[req_distinguished_name]
[v3_req]
basicConstraints = CA:TRUE
' > $C/openssl.conf
done
openssl genrsa -out root-ca/private/ca.key 2048
openssl req -config root-ca/openssl.conf -new -x509 -days 3650 -key root-ca/private/ca.key -sha256 -extensions v3_req -out root-ca/certs/ca.crt -subj '/CN=Root-ca'
openssl genrsa -out intermediate/private/intermediate.key 2048
openssl req -config intermediate/openssl.conf -sha256 -new -key intermediate/private/intermediate.key -out intermediate/certs/intermediate.csr -subj '/CN=localhost.'
openssl ca -batch -config root-ca/openssl.conf -keyfile root-ca/private/ca.key -cert root-ca/certs/ca.crt -extensions v3_req -notext -md sha256 -in intermediate/certs/intermediate.csr -out intermediate/certs/intermediate.crt
mkdir out
for I in `seq 1 3` ; do
 openssl req -new -keyout out/$I.key -out out/$I.request -days 365 -nodes -subj "/CN=$I.example.com" -newkey rsa:2048
 openssl ca -batch -config root-ca/openssl.conf -keyfile intermediate/private/intermediate.key -cert intermediate/certs/intermediate.crt -out out/$I.crt -infiles out/$I.request
done

服務(wù)器

nginx 配置

worker_processes 1;
events {
  worker_connections 1024;
}
stream{
  upstream backend{
    server 127.0.0.1:8080;
  }
  server {
    listen 8888 ssl;
    proxy_pass backend;
    ssl_certificate   intermediate.crt;
    ssl_certificate_key intermediate.key;
    ssl_verify_depth 2;
    ssl_client_certificate root.crt;
    ssl_verify_client optional_no_ca;
  }
}

客戶端

curl \
 -I \
 -vv \
 -x https://localhost:8888/ \
 --proxy-cert client1.crt \
 --proxy-key client1.key \
 --proxy-cacert ca.crt \
 https://www.baidu.com/

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接

相關(guān)文章

  • nginx實(shí)現(xiàn)請(qǐng)求轉(zhuǎn)發(fā)

    nginx實(shí)現(xiàn)請(qǐng)求轉(zhuǎn)發(fā)

    本文給大家分享的是使用nginx實(shí)現(xiàn)代理(請(qǐng)求轉(zhuǎn)發(fā))的教程及簡(jiǎn)單示例,非常實(shí)用,有需要的小伙伴可以參考下
    2017-07-07
  • 詳解Nginx如何代理UDP連接

    詳解Nginx如何代理UDP連接

    這篇文章主要為大家介紹了Nginx如何代理UDP連接的實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-06-06
  • 詳解Nginx實(shí)戰(zhàn)之讓用戶通過(guò)用戶名密碼認(rèn)證訪問(wèn)web站點(diǎn)

    詳解Nginx實(shí)戰(zhàn)之讓用戶通過(guò)用戶名密碼認(rèn)證訪問(wèn)web站點(diǎn)

    這篇文章主要介紹了詳解Nginx實(shí)戰(zhàn)之讓用戶通過(guò)用戶名密碼認(rèn)證訪問(wèn)web站點(diǎn),有興趣的可以了解一下。
    2016-11-11
  • centos7編譯安裝nginx的方法步驟

    centos7編譯安裝nginx的方法步驟

    這篇文章主要介紹了centos7編譯安裝nginx的方法步驟,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-07-07
  • 為Nginx自定義404,502錯(cuò)誤頁(yè)面的方法

    為Nginx自定義404,502錯(cuò)誤頁(yè)面的方法

    為Nginx自定義404,502錯(cuò)誤頁(yè)面的方法,需要的朋友可以參考下。
    2010-12-12
  • Nginx配置的rewrite編寫時(shí)last與break的區(qū)別分析

    Nginx配置的rewrite編寫時(shí)last與break的區(qū)別分析

    這篇文章主要介紹了Nginx配置的rewrite編寫時(shí)last與break的區(qū)別分析,簡(jiǎn)單來(lái)說(shuō)使用last會(huì)對(duì)server標(biāo)簽重新發(fā)起請(qǐng)求,而break就直接使用當(dāng)前的location中的數(shù)據(jù)源來(lái)訪問(wèn),需要的朋友可以參考下
    2016-01-01
  • nginx如何根據(jù)報(bào)文里字段轉(zhuǎn)發(fā)至不同地址

    nginx如何根據(jù)報(bào)文里字段轉(zhuǎn)發(fā)至不同地址

    要在 Nginx 中根據(jù) POST 請(qǐng)求的 JSON 負(fù)載中的 id 字段的值進(jìn)行轉(zhuǎn)發(fā),你可以使用 Nginx 的 ngx_http_lua_module 模塊,這個(gè)模塊允許你在 Nginx 配置中使用 Lua 腳本,本文介紹nginx如何根據(jù)報(bào)文里字段轉(zhuǎn)發(fā)至不同地址,感興趣的朋友一起看看吧
    2024-12-12
  • Nginx多ip部署多站點(diǎn)的實(shí)現(xiàn)步驟

    Nginx多ip部署多站點(diǎn)的實(shí)現(xiàn)步驟

    使用Nginx在具有多個(gè)IP地址的服務(wù)器上部署多個(gè)站點(diǎn),從而實(shí)現(xiàn)高效、安全的網(wǎng)站托管,本文主要介紹了Nginx多ip部署多站點(diǎn)的實(shí)現(xiàn)步驟,感興趣的可以了解一下
    2024-01-01
  • Nginx實(shí)現(xiàn)動(dòng)態(tài)內(nèi)容緩存的示例代碼

    Nginx實(shí)現(xiàn)動(dòng)態(tài)內(nèi)容緩存的示例代碼

    在Nginx中實(shí)現(xiàn)動(dòng)態(tài)內(nèi)容的緩存可以顯著提高性能,減少后端服務(wù)器的負(fù)載,本文就來(lái)介紹一下Nginx動(dòng)態(tài)內(nèi)容緩存實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-11-11
  • 詳解Nginx的超時(shí)keeplive_timeout配置步驟

    詳解Nginx的超時(shí)keeplive_timeout配置步驟

    Nginx 處理的每個(gè)請(qǐng)求均有相應(yīng)的超時(shí)設(shè)置,本文主要介紹了Nginx的超時(shí)keeplive_timeout配置步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05

最新評(píng)論

和平区| 玛沁县| 亚东县| 上栗县| 洛川县| 阿合奇县| 田阳县| 龙里县| 甘洛县| 亚东县| 英德市| 怀远县| 大宁县| 萨迦县| 岳阳县| 新昌县| 沧州市| 仪陇县| 类乌齐县| 北碚区| 霍邱县| 兰坪| 仁寿县| 隆尧县| 新田县| 高阳县| 高州市| 阜平县| 兰溪市| 赤壁市| 白水县| 灌南县| 金塔县| 建宁县| 六盘水市| 文化| 东源县| 铁岭县| 两当县| 电白县| 东兴市|