五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動(dòng)態(tài)

Nginx配置https原理及實(shí)現(xiàn)過(guò)程詳解

發(fā)布日期:2022-01-20 11:25 | 文章來(lái)源:源碼中國(guó)

使用linux實(shí)用工具certbot來(lái)生成https證書(shū)

這個(gè)工具是生成Let's Encrypt證書(shū),

Let's Encrypt數(shù)字證書(shū)認(rèn)證機(jī)構(gòu),Let's Encrypt 是由互聯(lián)網(wǎng)安全研究小組(ISRG,一個(gè)公益組織)提供的服務(wù)

提供免費(fèi)的SSL/TLS證書(shū)

2015年12月3日,該服務(wù)進(jìn)入公測(cè)階段,正式面向公眾。

2016年4月12日,該項(xiàng)目正式離開(kāi)Beta階段。

到2016年9月9日,Let's Encrypt 已經(jīng)發(fā)放 1000 萬(wàn)張證書(shū)。

因此對(duì)于大部分中小型網(wǎng)站來(lái)說(shuō),是一個(gè)值得考慮的選擇。

https配置的步驟

1打開(kāi) https://certbot.eff.org/ 選擇對(duì)應(yīng)操作系統(tǒng)與 Web 服務(wù)器

這里我選擇nginx服務(wù)器,CentOS7服務(wù)器上

2執(zhí)行命令,并根據(jù)需要修改相應(yīng)域名參數(shù)。

certbot要通過(guò)yum安裝,certbot被打包到epel源中,

所以安裝啟動(dòng)epel庫(kù),安裝epel源查看鏈接

https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F

啟動(dòng)epel源,可以使用手動(dòng)自己?jiǎn)?dòng)epel,也可以借助yum-config-manager命令來(lái)啟動(dòng)

安裝yum-config-manager

yum -y install yum-utils

啟動(dòng)epel

yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional

3安裝certbot

sudo yum install certbot python2-certbot-nginx

獲取證書(shū)的兩種方式:身份驗(yàn)證器和安裝程序

使用webRoot插件進(jìn)行安裝,這個(gè)要求你的服務(wù)器80端口能夠正常被訪問(wèn)到(這個(gè)域名是屬于你的)

webRoot插件通過(guò)certonly和--webroot(或者-w)在命令行上執(zhí)行命令

certbot certonly -w /var/www/example -d www.example.com

certbot certonly -w 可以被http訪問(wèn)到的webroot目錄 -d 要配置https的域名名稱

上面的 /var/www/example表示的是在nginx配置文件中root根節(jié)點(diǎn)所指向的根路徑

webroot插件的工作原理是為每個(gè)請(qǐng)求的域創(chuàng)建一個(gè)臨時(shí)文件${webroot-path}/.well-known/acme-challenge。

然后,Let的加密驗(yàn)證服務(wù)器發(fā)出HTTP請(qǐng)求,以驗(yàn)證每個(gè)請(qǐng)求的域的DNS是否解析為運(yùn)行certbot的服務(wù)器。

訪問(wèn)請(qǐng)求如下

66.133.109.36 - - [05/Jan/2016:20:11:24 -0500] "GET /.well-known/acme-challenge/HGr8U1IeTW4kY_Z6UIyaakzOkyQgPr_7ArlLgtZE8SX HTTP/1.1" 200 87 "-" "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)"

所以我們服務(wù)器需要放通.well-known/acme-challenge這個(gè)訪問(wèn)路徑

例如,

server
  {
    listen 80;
    server_name www.example.com; 
    index index.html ;
    root /var/www/example;
  
    。。。
  
    location ~ /.well-known {
      allow all;
    }
  }

具體的http配置文件

server
  {
    listen 80;
    server_name www.example.com; 
    index index.html ;
    root /var/www/www.example.com;

    location / {
      proxy_redirect off;
      proxy_pass http://localhost:8080;
      proxy_set_header Host $host;
      proxy_set_header  X-real-ip $remote_addr;
      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    #error_page  404  /404.html;
    location /nginx_status
    {
      #stub_status on;
      #access_log  off;
    }
    location ~ /.well-known {
      allow all;
    }
    location ~ /\.
    {
      deny all;
    }
access_log /data/log/nginx//var/www/www.example.com/-access.log;
    error_log /data/log/nginx//var/www/www.example.com/-error.log;
}

執(zhí)行完命令后,https證書(shū)就會(huì)生成在/etc/letsencrypt/live目錄下

certbot certonly -w /var/www/example -d www.example.com

比如上面的命令會(huì)生成證書(shū)/etc/letsencrypt/live/www.example.com/fullchain.pem

生成證書(shū)密鑰文件/etc/letsencrypt/live/www.example.com/privkey.pem

然后我們只需要為該域名加上https配置,我們nginx就配置完成https

https對(duì)應(yīng)443端口

具體https配置文件

server
  {
    listen 443 ssl http2;
    #listen [::]:443 ssl http2;
    server_name www.example.com;
    index index.html index.htm index.php default.html default.htm default.php;
    root /var/www/www.example.com/;
    
    ssl on;
    ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
    
   location / {
      proxy_redirect off;
      proxy_pass http://localhost:8080;
      proxy_set_header Host $host;
      proxy_set_header  X-real-ip $remote_addr;
      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    #error_page  404  /404.html;
    include enable-php-pathinfo.conf;
    location ~ /.well-known {
      allow all;
    }
    location ~ /\.
    {
      deny all;
    }
    access_log /data/log/nginx/www.example.com-ssl-access.log;
    error_log /data/log/nginx/www.example.com-ssl-error.logs;  
}

查看生產(chǎn)的證書(shū)

tree /etc/letsencrypt/live/

證書(shū)續(xù)簽

Let's Encrypt 生成的免費(fèi)證書(shū)為3個(gè)月時(shí)間,但是我們可以無(wú)限次續(xù)簽證書(shū)

certbot renew

使用定時(shí)器來(lái)自動(dòng)重新生成證書(shū)

0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew

centos6使用

1獲取certbot客戶端

wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto

2停止nginx

service nginx stop

3生成證書(shū)

./certbot-auto certonly --standalone --email `你的郵箱地址` -d `你的域名地址`

當(dāng)前網(wǎng)站有多個(gè)域名時(shí)需在后面增加,例如

./certbot-auto certonly --standalone --email `你的郵箱地址` -d `你的域名1` -d `你的域名2`

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。

版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開(kāi)通

自選配置、實(shí)時(shí)開(kāi)通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問(wèn)服務(wù)

1對(duì)1客戶咨詢顧問(wèn)

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部