欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Nginx服務(wù)器的SSL證書配置以及對(duì)SSL的反向代理配置

 更新時(shí)間:2016年01月08日 09:43:50   投稿:goldensun  
這篇文章主要介紹了Nginx服務(wù)器的SSL證書配置以及對(duì)SSL的反向代理配置方法,通常在開啟全站HTTPS時(shí)會(huì)用到,需要的朋友可以參考下

Nginx的SSL證書配置
1、使用openssl實(shí)現(xiàn)證書中心
由于是使用openssl架設(shè)私有證書中心,因此要保證以下字段在證書中心的證書、服務(wù)端證書、客戶端證書中都相同

Country Name
 State or Province Name
 Locality Name
 Organization Name
 Organizational Unit Name

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   = $dir/crl    # Where the issued crl are kept
 database  = $dir/index.txt  # database index file.
 #unique_subject = no     # Set to 'no' to allow creation of
 # several ctificates 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/crlnumber  # the current crl number          # must be commented out to leave a V1 CRL
 crl    = $dir/crl.pem   # The current CRL
 private_key  = $dir/private/cakey.pem# The private key
 RANDFILE  = $dir/private/.rand # private random number file
[ req_distinguished_name ]
 countryName      = Country Name(2 letter code)
 countryName_default    = CN
 countryName_min     = 2
 countryName_max     = 2
 stateOrProvinceName    = State or Province Name (full name)
 stateOrProvinceName_default  = FJ
 localityName     = Locality Name (eg, city)
 localityName_default   = FZ
 0.organizationName    = Organization Name (eg, company)
 0.organizationName_default  = zdz
 organizationalUnitName   = Organizational Unit Name (eg, section)
 organizationalUnitName_default = zdz

創(chuàng)建證書私鑰

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

2、創(chuàng)建服務(wù)器證書
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

3、創(chuàng)建客戶端瀏覽器證書

(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

 將文本格式的證書轉(zhuǎn)換成可以導(dǎo)入瀏覽器的證書

 openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12

4、配置nginx服務(wù)器驗(yàn)證

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.pem;
 ssl_session_timeout  5m;
 #ssl_verify_client  on;       服務(wù)器驗(yàn)證客戶端,暫時(shí)不開啟,讓沒有證書的客戶端可以訪問,先完成單向驗(yàn)證
 ssl_protocols   SSLv2 SSLv3 TLSv1;

SSL反向代理
1.修改nginx.conf配置

server {
  listen   443 ssl;
  server_name  www.dbjr.com.cn;
 
  ssl_certificate  ssl/www.dbjr.com.cn.crt;
  ssl_certificate_key ssl/www.dbjr.com.cn.key;
  ssl_prefer_server_ciphers on;
  keepalive_timeout 60;
 ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 10m;
 
  location / {
   proxy_pass http://www.dbjr.com.cn;
   proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    proxy_set_header  Accept-Encoding "";
   proxy_set_header  Host   $host;
   proxy_set_header  X-Real-IP  $remote_addr;
   proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header  X-Forwarded-Proto $scheme;
 add_header    Front-End-Https on;
   proxy_redirect  off;
  }
}

2.重啟服務(wù)

# /usr/local/nginx/sbin/nginx -t
# /usr/local/nginx/sbin/nginx -s reload

相關(guān)文章

  • Nginx中l(wèi)ocation匹配以及rewrite重寫跳轉(zhuǎn)詳解

    Nginx中l(wèi)ocation匹配以及rewrite重寫跳轉(zhuǎn)詳解

    訪問重寫 rewrite 是 Nginx HTTP 請(qǐng)求處理過程中的一個(gè)重要功能,下面這篇文章主要給大家介紹了Nginx中l(wèi)ocation匹配以及rewrite重寫跳轉(zhuǎn)的相關(guān)資料,需要的朋友可以參考下
    2022-03-03
  • 詳解Nginx限流配置

    詳解Nginx限流配置

    本文以示例的形式,由淺入深講解Nginx限流相關(guān)配置,是對(duì)簡(jiǎn)略的官方文檔的積極補(bǔ)充,感興趣的朋友跟隨小編一起看看吧
    2019-09-09
  • Nginx大并發(fā)優(yōu)化實(shí)戰(zhàn)

    Nginx大并發(fā)優(yōu)化實(shí)戰(zhàn)

    這篇文章主要介紹了Nginx大并發(fā)優(yōu)化實(shí)戰(zhàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-10-10
  • nginx如何開啟Gzip壓縮

    nginx如何開啟Gzip壓縮

    Gzip壓縮能顯著減小網(wǎng)站靜態(tài)資源如css、js、html的體積,大幅提升加載速度,它通過服務(wù)器端壓縮,瀏覽器端解壓,適用于大多數(shù)現(xiàn)代瀏覽器,但應(yīng)避免對(duì)已壓縮的圖片或大文件進(jìn)行Gzip壓縮,以免無(wú)效增加CPU負(fù)擔(dān),配置Gzip壓縮需在nginx的http塊內(nèi)設(shè)置并重啟nginx
    2024-09-09
  • 安裝配置php-fpm來(lái)搭建Nginx+PHP的生產(chǎn)環(huán)境

    安裝配置php-fpm來(lái)搭建Nginx+PHP的生產(chǎn)環(huán)境

    這篇文章主要介紹了安裝配置php-fpm來(lái)搭建Nginx+PHP的生產(chǎn)環(huán)境的方法,php-fpm的作用是將FastCGI進(jìn)程管理整合進(jìn)PHP包,需要的朋友可以參考下
    2016-01-01
  • Nginx配置防盜鏈保護(hù)靜態(tài)資源的詳細(xì)教程

    Nginx配置防盜鏈保護(hù)靜態(tài)資源的詳細(xì)教程

    防盜鏈?zhǔn)且环N通過檢查 HTTP 請(qǐng)求頭中的 Referer 字段來(lái)限制資源訪問的技術(shù),常用于保護(hù)圖片、視頻等靜態(tài)資源不被其他網(wǎng)站直接引用,以下是Nginx防盜鏈的原理、配置步驟以及測(cè)試方法,幫助你快速配置和驗(yàn)證防盜鏈功能,需要的朋友可以參考下
    2025-02-02
  • Nginx服務(wù)器下配置使用索引目錄的教程

    Nginx服務(wù)器下配置使用索引目錄的教程

    這篇文章主要介紹了Nginx服務(wù)器下配置使用索引目錄的教程,包括自帶的auto_index和使用fancy插件美化的用法,需要的朋友可以參考下
    2016-01-01
  • 配置Nginx以實(shí)現(xiàn)自動(dòng)重啟的方法

    配置Nginx以實(shí)現(xiàn)自動(dòng)重啟的方法

    要實(shí)現(xiàn)Nginx的自動(dòng)重啟,我們通常會(huì)借助一個(gè)叫做systemd的工具,systemd是Linux系統(tǒng)中的一個(gè)服務(wù)管理器,它可以幫助我們管理系統(tǒng)的各種服務(wù),包括Nginx
    2025-02-02
  • nginx rewrite 偽靜態(tài)配置參數(shù)和使用例子

    nginx rewrite 偽靜態(tài)配置參數(shù)和使用例子

    nginx下偽靜態(tài)配置參數(shù)詳細(xì)說(shuō)明,使用nginx的朋友,nginx rewrite 偽靜態(tài)配置參數(shù)和使用例子 附正則使用說(shuō)明
    2010-07-07
  • NGINX基于cookie針對(duì)同一域名進(jìn)行分流轉(zhuǎn)發(fā)

    NGINX基于cookie針對(duì)同一域名進(jìn)行分流轉(zhuǎn)發(fā)

    本文介紹了利用NGINX基于cookie進(jìn)行多環(huán)境分流的方法,通過在Docker中部署兩個(gè)后端NGINX容器,并在前端NGINX配置中設(shè)置map規(guī)則,根據(jù)cookie值將請(qǐng)求分發(fā)到不同后端,感興趣的可以了解一下
    2025-07-07

最新評(píng)論