Nginx 通过 certbot 为网站自动配置 SSL 证书并续期

news/2024/5/9 17:37:16/文章来源:https://blog.csdn.net/weixin_30877755/article/details/99283491

目录

  • 一、背景知识
    • 1.1、http 和 https 是什么?
    • 1.2、SSL/TLS 是什么?
    • 1.3、为什么要部署 https?
    • 1.4、怎么部署 https 呢?
    • 1.5、怎么获得 SSL 安全证书呢?
  • 二、Let’s Encrypt 及 Certbot 简介
    • 2.1、Authenticators 和 Installers
    • 2.2、plugin 说明
    • 2.3、安装 certbot
  • 三、Certbot 为 nginx 自动获取安装证书
    • 3.1、生成证书
    • 3.2、配置证书
    • 3.3、更新证书
  • 四、Certbot Webroot 模式配置证书
    • 4.1、配置虚拟主机
    • 4.2、申请证书
    • 4.3、配置证书
    • 4.4 配置站点 bbs2

一、背景知识

1.1、http 和 https 是什么?

简单来说,http 是一个传输网页内容的协议,比如你看到的 http 开头的网站 http://www.163.com ,其网页上的文字、图片、 CSS 、 JS 等文件都是通过 http 协议传输到我们的浏览器,然后被我们看到。

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

而 https 可以理解为“ HTTP over SSL/TLS ”,好端端的 http 为什么需要“ over SSL/TLS ”呢,因为 http 是明文传输的,通过 http 协议传输的内容很容易被偷看和篡改,为了安全(你肯定不想被人偷看或者篡改网页内容吧,比如网站银行密码什么的。)就为 http 协议再加上了一层 SSL/TLS 安全协议,所以就有了 https 。

1.2、SSL/TLS 是什么?

“ HTTP over SSL/TLS ”字面意思就是带”安全套接层”的 http 协议,内心纯洁的同学也可以理解为“带安全套的 http ”,因为带了安全套,所以当然会比较安全。其中 SSL 是“ Secure Sockets Layer ” 的缩写,是“安全套接层”的意思。 TLS 是 “Transport Layer Security” 的缩写,是 ” 传输层安全协议 ” 的意思。 SSL 和 TLS 是同一个东西的不同阶段,理解为同一个东西也行,都是安全协议就对了。

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

1.3、为什么要部署 https?

说到底,就是 https 更安全。甚至为了安全,一个专业可靠的网站, https 是必须的。 Firefox 和 Chrome 都计划将没有配置 SSL 加密的 http 网站标记为不安全(貌似 Firefox 50 已经这么干了),目前它们也正在联合其他相关的基金会与公司推动整个互联网 https 化,现在大家访问的一些主要的网站。如 Google 多年前就已经全部启用 https ,国内的淘宝、搜狗、知乎、百度等等也全面 https 了。甚至 Google 的搜索结果也正在给予 https 的网站更高的排名和优先收录权。

1.4、怎么部署 https 呢?

你只需要有一张被信任的 CA ( Certificate Authority )也就是证书授权中心颁发的 SSL 安全证书,并且将它部署到你的网站服务器上。一旦部署成功后,当用户访问你的网站时,浏览器会在显示的网址前加一把小绿锁,表明这个网站是安全的,当然同时你也会看到网址前的前缀变成了 https ,不再是 http 了。

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

1.5、怎么获得 SSL 安全证书呢?

理论上,我们自己也可以签发 SSL 安全证书,但是我们自己签发的安全证书不会被主流的浏览器信任,所以我们需要被信任的证书授权中心( CA )签发的安全证书。而一般的 SSL 安全证书签发服务都比较贵,比如 Godaddy 、 GlobalSign 等机构签发的证书一般都需要20美金一年甚至更贵,不过为了加快推广 https 的普及, EEF 电子前哨基金会、 Mozilla 基金会和美国密歇根大学成立了一个公益组织叫 ISRG ( Internet Security Research Group ),这个组织从 2015 年开始推出了 Let’s Encrypt 免费证书。这个免费证书不仅免费,而且还相当好用,所以我们就可以利用 Let’s Encrypt 提供的免费证书部署 https 了。那么怎么获得 Let’s Encrypt 安全证书,并且将它部署在自己的网站服务器上呢?这就是这篇文章要讲的内容了。

二、Let’s Encrypt 及 Certbot 简介

前面已经介绍过, Let’s Encrypt 是 一个叫 ISRG ( Internet Security Research Group ,互联网安全研究小组)的组织推出的免费安全证书计划。参与这个计划的组织和公司可以说是互联网顶顶重要的先驱,除了前文提到的三个牛气哄哄的发起单位外,后来又有思科(全球网络设备制造商执牛耳者)、 Akamai 加入,甚至连 Linux 基金会也加入了合作,这些大牌组织的加入保证了这个项目的可信度和可持续性。

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

后来 ISRG 的发起者 EFF (电子前哨基金会)为 Let’s Encrypt 项目发布了一个官方的客户端 Certbot ,利用它可以完全自动化的获取、部署和更新安全证书。这真是非常容易、方便呀,所以我们就可以直接使用官方客户端,不需要再使用第三方的工具了。虽然第三方工具也可以使用,但是官方工具更权威,风险也更小,而且遇到问题也更容易解决,毕竟有官方的支持。何况 Certbot 确实非常方便,也比所有的第三方工具都更方便,何乐而不用呢?

2.1、Authenticators 和 Installers

Certbot 支持两种类型的 plugin,一种是用来获取和安装证书的,成为称为 Authenticators;另外一种是用来安装证书的,称为 Installers。有的 plugin 支持一种,有的两种都支持,如 nginx。
Authenticators plugin 使用 certonly 命令来获取证书,而 Installers plugin 使用install命令来安装证书。

2.2、plugin 说明

下面列举几个常用的 plugin 作简要说明:

  • Webroot:本地有运行 webserver 并且有能力修改其配置,就可以用该种方式(创建隐藏文件.well-known),获取证书时无需暂停 webserver 的运行。
  • Standalone:服务器未运行 webserver 可以使用该方式,要保持 80 或 443 端口开放。
  • Nginx:自动获取和安装证书(自动修改配置文件)。

2.3、安装 certbot

Certbot 的官方网站是 https://certbot.eff.org/ ,打开这个链接选择自己使用的 web server 和操作系统,EFF 官方会给出详细的使用方法,以下以本网站域名( bbs.wzlinux.com )举例。

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

我们的系统环境为 CentOS 7,Web 服务器为 epel 源中的 nginx,只是为了掩饰安装证书,没有做什么网页,大家了解这个过程为主,我们使用下面命令进行安装 certbot。

yum install certbot python2-certbot-nginx

三、Certbot 为 nginx 自动获取安装证书

3.1、生成证书

我们在使用 certbot 生成证书之前,要把域名解析到当前的服务器,使用令生certbot --nginx成证书,并且会帮我们自动配置到 nginx 上面,过程中需要我们输入邮箱地址。

[root@lnmp-1 ~]# certbot --nginx
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): wangzan18@126.com
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Starting new HTTPS connection (1): supporters.eff.org
No names were found in your configuration files. Please enter in your domain
name(s) (comma and/or space separated)  (Enter 'c' to cancel): bbs.wzlinux.com
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for bbs.wzlinux.com
Waiting for verification...
Cleaning up challenges
Resetting dropped connection: acme-v02.api.letsencrypt.org
Deploying Certificate to VirtualHost /etc/nginx/nginx.confPlease choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Redirecting all traffic on port 80 to ssl in /etc/nginx/nginx.conf- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://bbs.wzlinux.comYou should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=bbs.wzlinux.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -IMPORTANT NOTES:- Congratulations! Your certificate and chain have been saved at:/etc/letsencrypt/live/bbs.wzlinux.com/fullchain.pemYour key file has been saved at:/etc/letsencrypt/live/bbs.wzlinux.com/privkey.pemYour cert will expire on 2019-07-25. To obtain a new or tweakedversion of this certificate in the future, simply run certbot againwith the "certonly" option. To non-interactively renew *all* ofyour certificates, run "certbot renew"- Your account credentials have been saved in your Certbotconfiguration directory at /etc/letsencrypt. You should make asecure backup of this folder now. This configuration directory willalso contain certificates and private keys obtained by Certbot somaking regular backups of this folder is ideal.- If you like Certbot, please consider supporting our work by:Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donateDonating to EFF:                    https://eff.org/donate-le

按照提示输入自己的信息即可,如果希望自己手动配置 nginx 证书,可以使用下面的命令。

certbot --nginx certonly

3.2、配置证书

目前已经自动帮我们配置证书了,我们可以看下配置的形式,后续可以自己配置。

server {server_name bbs.wzlinux.com;   # managed by Certbotroot         /usr/share/nginx/html;# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;location / {}error_page 404 /404.html;location = /40x.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}listen [::]:443 ssl ipv6only=on; # managed by Certbotlisten 443 ssl; # managed by Certbotssl_certificate /etc/letsencrypt/live/bbs.wzlinux.com/fullchain.pem; # managed by Certbotssl_certificate_key /etc/letsencrypt/live/bbs.wzlinux.com/privkey.pem; # managed by Certbotinclude /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbotssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot}server {if ($host = bbs.wzlinux.com) {return 301 https://$host$request_uri;} # managed by Certbotlisten       80 ;listen       [::]:80 ;server_name bbs.wzlinux.com;return 404; # managed by Certbot}

3.3、更新证书

既然已经按照好了,我们可以查看一下证书的安装情况。

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=
watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

出于安全策略, Let’s Encrypt 签发的证书有效期只有 90 天,所以需要每隔三个月就要更新一次安全证书,虽然有点麻烦,但是为了网络安全,这是值得的也是应该的。好在 Certbot 也提供了很方便的更新方法。
我们可以在 www.ssllabs.com 测试证书是否正常。

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

  • 测试一下更新,这一步没有在真的更新,只是在调用 Certbot 进行测试。
certbot renew --dry-run

建议在服务器上面添加一个定时任务,让服务器定时请求进行更新。

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

四、Certbot Webroot 模式配置证书

这里我不想使用CertBot的standalone模式,这个模式虽然可以配置好服务器,但是以后Renew的时候,需要让服务停止一下,再启动。因此抛弃这个模式,我们使用Webroot配置模式。

因为,CertBot在验证服务器域名的时候,会生成一个随机文件,然后CertBot的服务器会通过HTTP访问你的这个文件,因此要确保你的Nginx配置好,以便可以访问到这个文件。

我这里的 web 服务器使用 LNMP 一键安装包来安装的,我们之间为 其中的 nginx 配置证书,首先我们先生成证书。

4.1、配置虚拟主机

我们使用的 lnmp 一键安装包进行安装的,我们可以直接使用命令 lnmp vhost add命令添加我们需要的主机。

[root@test ~]# lnmp vhost add
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Please enter domain(example: www.lnmp.org): bbs1.wzlinux.comYour domain: bbs1.wzlinux.com
Enter more domain name(example: lnmp.org *.lnmp.org): 
Please enter the directory for the domain: bbs1.wzlinux.com
Default directory: /home/wwwroot/bbs1.wzlinux.com: 
Virtual Host Directory: /home/wwwroot/bbs1.wzlinux.com
Allow access log? (y/n) 
Disable access log.
Please enter Administrator Email Address: 
Administrator Email Address will set to webmaster@example.com!
Create database and MySQL user with same name (y/n) 
Add SSL Certificate (y/n) nPress any key to start create virtul host...Create Virtul Host directory......
set permissions of Virtual Host directory......
Test Nginx configure file......
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfulReload Nginx......
Test Apache configure file...
test apache configure... Syntax OKdone
Restart Apache...
graceful apache...  done
================================================
Virtualhost infomation:
Your domain: bbs1.wzlinux.com
Home Directory: /home/wwwroot/bbs1.wzlinux.com
Enable log: yes
Create database: no
Create ftp account: no
================================================

4.2、申请证书

[root@test ~]# certbot certonly --webroot -w /home/wwwroot/bbs1.wzlinux.com/ -d bbs1.wzlinux.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): wangzan18@126.com
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Starting new HTTPS connection (1): supporters.eff.org
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for bbs1.wzlinux.com
Using the webroot path /home/wwwroot/bbs1.wzlinux.com for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Resetting dropped connection: acme-v02.api.letsencrypt.orgIMPORTANT NOTES:- Congratulations! Your certificate and chain have been saved at:/etc/letsencrypt/live/bbs1.wzlinux.com/fullchain.pemYour key file has been saved at:/etc/letsencrypt/live/bbs1.wzlinux.com/privkey.pemYour cert will expire on 2019-08-06. To obtain a new or tweakedversion of this certificate in the future, simply run certbotagain. To non-interactively renew *all* of your certificates, run"certbot renew"- Your account credentials have been saved in your Certbotconfiguration directory at /etc/letsencrypt. You should make asecure backup of this folder now. This configuration directory willalso contain certificates and private keys obtained by Certbot somaking regular backups of this folder is ideal.- If you like Certbot, please consider supporting our work by:Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donateDonating to EFF:                    https://eff.org/donate-le

4.3、配置证书

生成的证书位置如下:

[root@test ~]# ll /etc/letsencrypt/live/bbs1.wzlinux.com/
total 4
lrwxrwxrwx. 1 root root  40 May  8 18:50 cert.pem -> ../../archive/bbs1.wzlinux.com/cert1.pem
lrwxrwxrwx. 1 root root  41 May  8 18:50 chain.pem -> ../../archive/bbs1.wzlinux.com/chain1.pem
lrwxrwxrwx. 1 root root  45 May  8 18:50 fullchain.pem -> ../../archive/bbs1.wzlinux.com/fullchain1.pem
lrwxrwxrwx. 1 root root  43 May  8 18:50 privkey.pem -> ../../archive/bbs1.wzlinux.com/privkey1.pem
-rw-r--r--. 1 root root 692 May  8 18:50 README

目前生成的 nginx 配置文件/usr/local/nginx/conf/vhost/bbs1.wzlinux.com.conf如下:

server{listen 80;#listen [::]:80;server_name bbs1.wzlinux.com ;index index.html index.htm index.php default.html default.htm default.php;root  /home/wwwroot/bbs1.wzlinux.com;#error_page   404   /404.html;# Deny access to PHP files in specific directory#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }include proxy-pass-php.conf;location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires      30d;}location ~ .*\.(js|css)?${expires      12h;}location ~ /.well-known {allow all;}location ~ /\.{deny all;}access_log off;}

然后我们为其添加 SSL 证书,修改后的配置文件如下:

server{listen 443 ssl http2;#listen [::]:443 ssl http2;server_name     bbs1.wzlinux.com;index index.html index.htm index.php default.html default.htm default.php;root  /home/wwwroot/bbs1.wzlinux.com;ssl on;ssl_certificate /etc/letsencrypt/live/bbs1.wzlinux.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/bbs1.wzlinux.com/privkey.pem;ssl_session_timeout 5m;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on;ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";ssl_session_cache builtin:1000 shared:SSL:10m;# openssl dhparam -out /usr/local/nginx/ssl/dhparam.pem 2048#ssl_dhparam /usr/local/nginx/ssl/dhparam.pem;#error_page   404   /404.html;# Deny access to PHP files in specific directory#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }include enable-php.conf;location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires      30d;}location ~ .*\.(js|css)?${expires      12h;}location ~ /.well-known {allow all;}location ~ /\.{deny all;}access_log  off;
}server{listen          80;server_name bbs1.wzlinux.com;return 301 https://$server_name$request_uri;
}

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

4.4 配置站点 bbs2

在做一个bbs2.wzlinux.com,同样的做法去生成证书。

[root@test bbs2.wzlinux.com]# certbot certonly --webroot -w /home/wwwroot/bbs2.wzlinux.com/ -d bbs2.wzlinux.com --email wangzan18@126.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for bbs2.wzlinux.com
Using the webroot path /home/wwwroot/bbs2.wzlinux.com for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Resetting dropped connection: acme-v02.api.letsencrypt.orgIMPORTANT NOTES:- Congratulations! Your certificate and chain have been saved at:/etc/letsencrypt/live/bbs2.wzlinux.com/fullchain.pemYour key file has been saved at:/etc/letsencrypt/live/bbs2.wzlinux.com/privkey.pemYour cert will expire on 2019-08-06. To obtain a new or tweakedversion of this certificate in the future, simply run certbotagain. To non-interactively renew *all* of your certificates, run"certbot renew"- If you like Certbot, please consider supporting our work by:Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donateDonating to EFF:                    https://eff.org/donate-le

配置后的 nginx 配置文件内容为:

server{listen 443 ssl http2;#listen [::]:443 ssl http2;server_name     bbs2.wzlinux.com;index index.html index.htm index.php default.html default.htm default.php;root  /home/wwwroot/bbs2.wzlinux.com;ssl on;ssl_certificate /etc/letsencrypt/live/bbs2.wzlinux.com/fullchain.pem;     ssl_certificate_key /etc/letsencrypt/live/bbs2.wzlinux.com/privkey.pem;ssl_trusted_certificate /etc/letsencrypt/live/bbs2.wzlinux.com/chain.pem;ssl_session_timeout 5m;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on;ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";ssl_session_cache builtin:1000 shared:SSL:10m;# openssl dhparam -out /usr/local/nginx/ssl/dhparam.pem 2048#ssl_dhparam /usr/local/nginx/ssl/dhparam.pem;#error_page   404   /404.html;# Deny access to PHP files in specific directory#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }include enable-php.conf;location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires      30d;}location ~ .*\.(js|css)?${expires      12h;}location ~ /.well-known {allow all;}location ~ /\.{deny all;}access_log  off;
}server{listen          80;server_name bbs2.wzlinux.com;return 301 https://$server_name$request_uri;
}

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

最后我们给服务器添加一个定时任务。

0 3 */7 * * /bin/certbot renew --force-renew --disable-hook-validation --renew-hook "/etc/init.d/nginx reload"

由此我们也可以看出,同一个 IP 的服务器可以为多个域名同时做 https。

最后祝愿我们所有的站点都升级为 https,让 https 人人都可以用得起。

转载于:https://www.cnblogs.com/wzlinux/p/11188419.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_818680.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

部署社区网站,搭建SVN、nginx、PHP,部署MFS并挂载,发布上线

概述: 社交网站的第一个版本部署在LNMP平台之上,前段为Nginx服务器,通过fastcgi协议访问后端的PHP服务器。为了保证数据安全,要求搭建MySQL数据库主从集群。 项目介绍: 本项目案例结合SVN、LNMP和MySQL三种环境&#x…

《大型网站架构技术》系列分享专栏

2019独角兽企业重金招聘Python工程师标准>>> 在这里整理一些大型网站架构方面的技术文章,包括大型网站存储,架构,静态化处理,高并发,高性能方面的问题处理,解决方案等知识 《大型网站架构技术》…

阿里云官方网站免费套餐怎么抢

阿里云推出包含云服务器 ECS、负载均衡、云数据库 RDS、云数据库 Redis 版、云数据库 Mongodb 版、弹性公网 IP、CDN、对象存储 OSS、文件存储 NAS等40核心云产品,6个月免费使用何为免费套餐,其实就是让你先体验,觉得好用,易用&am…

一步步构建大型网站架构

2019独角兽企业重金招聘Python工程师标准>>> 之前我简单向大家介绍了各个知名大型网站的架构,亿万用户网站MySpace的成功秘密、Flickr架构、YouTube网站架构、PlentyOfFish 网站架构学习、WikiPedia技术架构学习笔记。这几个都很典型,我们可以…

html:demo网站学习

学习网站https://www.sc-edu.com 涉及知识如下&#xff1a; 目录HTML < ul> 标签HTML lang 属性HTML 标签的 alt 属性CSS 选择器CSS position绝对定位&#xff1a;absolute relativeCSS background-position 属性CSS3 animation(动画)属性 与 keyframes 规则CSS paddin…

html:写网站时遇到的问题及解决

目录01 绝对路径改相对路径出错&#xff1a;图片无法显示02 两端文字空开&#xff0c;且每行这两端文字对齐03 在一行&#xff0c;一侧显示文字&#xff0c;一侧显示图片04 动画效果&#xff0c;文字乱跑05 padding 和 margin01 绝对路径改相对路径出错&#xff1a;图片无法显示…

四招避免SEO优化过度

在对网站进行优化的过程中&#xff0c;很多人往往会将所看到的优化方法不分青红皂白的一律应用&#xff0c;但这样一来就往往会出现优化过度的现象&#xff0c;优化过度甚至比不优化还要对网站有危害&#xff0c;只需要注意以下四个方面&#xff0c;就可以避免在优化网站中经常…

MOSS通过此命令注册模板,web应用程序可以根据stp模块生成网站集

注&#xff1a;C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin stsadm –o addtemplate –title 凤凰小学模版 –filename d:\fenghuangxiaoxue.stp MOSS部署常用的stsadm命令行 常用的stsadm命令行参数有&#xff1a; 1、installfeature、uni…

如何部署互动百科的开源wiki建站系统

最近想在技术部门内部搭建一个知识共享平台&#xff0c;经过一番了解和相关资料的查阅&#xff0c;选定了互动百科的开源wiki系统。选定互动wiki&#xff08;下文简称hdwiki)&#xff0c;主要的原因有如下几个方面&#xff1a; 1.中文版。这样对于我个人或者团队内部成员而言&a…

国外人经常上的网站,即全球各个领域最大的互联网网站

由于身处的行业原因&#xff0c;我经常上中国以外的互联网&#xff0c;其实全世界的网民跟国内的网民差不多&#xff0c;他们也经常上网&#xff0c;玩空间、网络视频、分享照片、写博客。由于国内对于互联网的封锁&#xff0c;所以国内大部分的童鞋并不了解外国人的上网都去哪…

分享一个交友网站源码-类Facebook

源码地址&#xff1a; https://gitee.com/tonygeli/social

wordpress账号无法登陆_外贸独立站Wordpress+WooCommerce建站记录贴

一、打开SiteGround网站&#xff0c;进行虚拟主机购买二、选择WooCommerce虚拟主机&#xff0c;第一个只能建一个网站&#xff0c;第二个建立无数个网站&#xff0c;第三个更贵&#xff0c;以后升级可选&#xff1b;我选择第二个&#xff1b;三、在购买的时候在SiteGround上选择…

VS2012下开发MVC4网站(EF出现找不到元数据)

这个错误出现的莫名其妙,在项目里,连了两个数据库,一个2008,一个mysql5.5,调试运行,一点问题都没有,但是发布到IIS7里面,就提示找不到元数据了. 找了好多办法,什么该连接串中的&quot;为,还有一个把metedata的配置,改为具体的名称res://*/test.csdl...把*改成具体的命名空间…

婚纱网站php源码,婚纱摄影宣传网站模板(PHP 源码)

★模板安装方法★1、将web文件夹里的文件覆盖到网站根目录.2、安装dede系统。(如果您已经安装,请跳过本步.)直接运行&#xff1a;http://www.yourname.com/install/index.php (请换成你的域名)3、还原数据库&#xff1a;1)进入dede后台&#xff0c;找到‘系统’-‘数据库备份/还…

php程序设置ip黑名单,网站访客IP黑名单源码有效屏蔽ip(PHP实现,CC防火墙)

在其他地方看到的&#xff0c;感觉不错就 分享一下..网站IP黑名单2组源代码可有效阻止ip(在PHP中实现&#xff0c;可以用作CC防火墙)&#xff0c;一组是单页banIP版本(支持PHP5.4或更高版本&#xff0c;未选择服务器环境) &#xff0c;系统未选中)一组是整个站点的banIP版本(支…

qq修改实名认证已达上限_实名认证修改申请网站 腾讯游戏王者荣耀、战场:健康系统实名认证修改方法...

解除成长守护平台可以解除健康系统的限制吗&#xff1f;成长守护平台和健康系统都属于腾讯未成年人保护体系&#xff0c;二者相互独立运行&#xff0c;解绑成长守护平台不能解除健康系统的限制。腾讯健康系统实名认证修改方法 仅可修改一次 (未成年无效) 这个修改方法 这两天都…

搜索引擎排名都选乐云seo_到9012年搜索引擎都不一定会死,但百家号真的可以用来做SEO优化...

小谷这两天被《搜索引擎百度已死》这篇文章刷屏了&#xff0c;文章主旨就是指责百度搜索结果一半以上会指向百度自家产品&#xff0c;尤其是百家号&#xff0c;而百家号充斥着大量营销和质量低劣的内容&#xff0c;也导致百度搜索结果的内容质量大幅下滑。意思就是百度正在利用…

visual studio 2013发布网站

visual studio 2013发布网站 转载于:https://www.cnblogs.com/Gxiaopan/p/4341610.html

jmh气象传真图网站_在冬奥滑雪场,他凭着气象信息,念好一本生意经_政务_澎湃新闻...

原创 不同视角的气象 中国气象局随着冬季来临冰雪运动再次“热”了起来&#xff01;河北省张家口市崇礼区距离北京220公里目前已建成7家大型滑雪场拥有169条雪道总长度162公里作为2022年冬奥会雪上项目的主要举办地崇礼早已是世界闻名的滑雪胜地这个冬季这里再次涌入了大批滑雪…

怎么用DreamWare新建立一个静态网站的站点

可以上面的图可以看出首先需要用F8确定这个文件是勾选的&#xff0c;然后在D盘建立"华为"文件夹&#xff0c;然后在里面建js&#xff0c;css,image文件夹&#xff0c;然后在DW里面点击站点 然后点击管理站点&#xff0c;有一个新建站点&#xff0c;选择"华为&qu…