亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

Nginx的SSL證書配置
1、使用openssl實現(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ù)器驗證

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ù)器驗證客戶端,暫時不開啟,讓沒有證書的客戶端可以訪問,先完成單向驗證
 ssl_protocols   SSLv2 SSLv3 TLSv1;

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

server {
  listen   443 ssl;
  server_name  chabaoo.cn;
 
  ssl_certificate  ssl/chabaoo.cn.crt;
  ssl_certificate_key ssl/chabaoo.cn.key;
  ssl_prefer_server_ciphers on;
  keepalive_timeout 60;
 ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 10m;
 
  location / {
   proxy_pass http://chabaoo.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手動編譯、安裝超詳細(xì)教程

    Nginx手動編譯、安裝超詳細(xì)教程

    Nginx安裝除了編譯以外,我們還可以直接用操作系統(tǒng)上自帶的工具比如說yum、apt-get直接安裝,這篇文章主要介紹了Nginx手動編譯、安裝超超詳解,需要的朋友可以參考下
    2023-09-09
  • nginx如何設(shè)置服務(wù)器響應(yīng)時間長短

    nginx如何設(shè)置服務(wù)器響應(yīng)時間長短

    本文主要介紹了nginx如何設(shè)置服務(wù)器響應(yīng)時間長短,主要介紹了兩種方法,具有一定的參考價值,感興趣的可以了解一下
    2023-09-09
  • 利用Nginx處理Vue開發(fā)環(huán)境的跨域的方法

    利用Nginx處理Vue開發(fā)環(huán)境的跨域的方法

    這篇文章主要介紹了利用Nginx處理Vue開發(fā)環(huán)境的跨域的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-06-06
  • Nginx訪問日志及錯誤日志參數(shù)說明

    Nginx訪問日志及錯誤日志參數(shù)說明

    這篇文章主要介紹了Nginx訪問日志及錯誤日志參數(shù)說明,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-11-11
  • nginx如何配置x-forwarded-for頭部

    nginx如何配置x-forwarded-for頭部

    這篇文章主要介紹了nginx如何配置x-forwarded-for頭部,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-01-01
  • Nginx的nginx.conf配置文件中文注釋說明

    Nginx的nginx.conf配置文件中文注釋說明

    這篇文章主要介紹了Nginx的nginx.conf配置文件中文注釋說明,本文是個人注釋版,在生產(chǎn)環(huán)境中經(jīng)常使用,需要的朋友可以參考下
    2014-12-12
  • nginx反向代理配置400,404,502等狀態(tài)的自定義頁面問題

    nginx反向代理配置400,404,502等狀態(tài)的自定義頁面問題

    這篇文章主要介紹了nginx反向代理配置400,404,502等狀態(tài)的自定義頁面問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • Nginx配置防盜鏈的完整步驟

    Nginx配置防盜鏈的完整步驟

    這篇文章主要給大家介紹了關(guān)于Nginx配置防盜鏈的完整步驟,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Nginx具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • Nginx的優(yōu)化、安全與防盜鏈實例詳解

    Nginx的優(yōu)化、安全與防盜鏈實例詳解

    防止盜鏈不僅能保護版權(quán),又節(jié)約了不少流量,下面這篇文章主要給大家介紹了關(guān)于Nginx優(yōu)化、安全與防盜鏈的相關(guān)資料,文中通過圖文以及實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-10-10
  • nginx禁用特定ip的方法詳解

    nginx禁用特定ip的方法詳解

    Nginx是一款輕量級的Web服務(wù)器、反向代理服務(wù)器及電子郵件代理服務(wù)器,其特點是占有內(nèi)存少,并發(fā)能力強,事實上nginx的并發(fā)能力確實在同類型的網(wǎng)頁服務(wù)器中表現(xiàn)較好,本文主要介紹利用nginx來禁用特定ip的方法,需要的朋友可以參考下
    2023-09-09

最新評論