美文网首页
围绕HTTP、HTTPS、HTTP/2的进行的实践

围绕HTTP、HTTPS、HTTP/2的进行的实践

作者: tangyefei | 来源:发表于2019-06-13 18:06 被阅读0次

这块涉及的知识点发现比想象的多很多,慢慢把学习到的知识点,完善到这篇博客中:

更新时间 内容
2019年6月13日 HTTPS的作用
2019年6月14日 在博客使用HTTPS

1. HTTPS的作用

阮一峰:SSL/TLS协议运行机制的概述

(1) 所有信息都是加密传播,第三方无法窃听。

(2) 具有校验机制,一旦被篡改,通信双方会立刻发现。

(3) 配备身份证书,防止身份被冒充

StackOverflow: 谁能窃听HTTP请求中的数据

2. 在博客使用HTTPS

参考 阮一峰:HTTPS 升级指南,使用Let's Encrypt 提供的工具选择 Linux + Centos7,只执行如下两个命令即可生成证书:

$ sudo yum install certbot python2-certbot-nginx
$ sudo certbot --nginx

IMPORTANT NOTES:
 - Unable to install the certificate
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/tangyefei.cn/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/tangyefei.cn/privkey.pem
   Your cert will expire on 2019-09-11. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.

再把pem文件的内容拷贝到 SSL Certificate Check(需翻墙) 校验下格式正确。

阮一峰的提到了 用 SSL Labs Server Test 检查一下证书是否生效,得到的结果如下,怀疑是因为服务器在国内(腾讯云)上,所以无法连接。

image.png

索性直接配置nginx再说,不去管它校验,这篇关于Nginx中配置ssl的文章 可能比阮一峰介绍的更详细并且不容易引起误解:

server{
        listen 80;
        server_name example.com www.example.com;
        return 301 https://www.example.com$request_uri;
}
server {
        listen 443 ssl http2;
        server_name example.com www.example.com;
        # SSL/TLS configs
        ssl on;
        ssl_certificate /etc/ssl/certs/example_com_cert_chain.crt;
        ssl_certificate_key /etc/ssl/private/example_com.key;
}    

总结下来就是:普通的访问会来到80端口,然后重定向到https;https会访问443端口(需要使用云服务器的配置中打开出参规则),并且打配置ssl相关的参数。重启nginx这样一来,通过http和https方式都能访问到个人的站点了。

此外,腾讯云的证书管理 中也可以申请免费的证书,可以作为一个选择。

最后令人觉得奇怪的是:等到自己能按照 http 和 https 访问个人博客以后,再用 SSL Labs Server Test 进行校验,发现居然通过了(如下图)?怀疑是之前443端口没打开的缘故?然而把在腾讯云上把443的出参规则删除掉了,丝毫不影响https方式的访问,不理解了(待解答)。

image.png

相关文章

  • 围绕HTTP、HTTPS、HTTP/2的进行的实践

    这块涉及的知识点发现比想象的多很多,慢慢把学习到的知识点,完善到这篇博客中: 1. HTTPS的作用 阮一峰:SS...

  • HTTP/1.0、HTTP/1.1、HTTP/2、HTTPS

    1. HTTP发展历史 HTTP(超文本传输协议,HyperText Transfer Protocol)是建立在...

  • http 升级https 实践

    注意事项: http下可以使用https的资源,https下使用http资源时,对于js等类型资源不能加载, 一般...

  • HTTP、HTTP2和 HTTPS

    HTTP HTTP 超文本传输协议,它定义了客户端和服务器之间交换报文的格式和方式,它使用 TCP 作为传输层协议...

  • nginx http、 https、 http2配置

    nginx http、 https、 http2配置 nginx版本:1.12.2 *注:以下配置重启才能生效 h...

  • HTTP、HTTPS、HTTP版本的演进

    文章思路 HTTP基本概念: 基本概念 - HTTP是什么? 状态码 - HTTP常见的状态码有哪些? 首部字段 ...

  • Http Https SPDY

    HTTP,HTTP2.0,SPDY,HTTPS你应该知道的一些事 HTTP2.0的奇妙日常 淘宝全站HTTPS实践...

  • HTTP/HTTPS

    说明 HTTP协议即超文本传送协议(Hypertext Transfer Protocol ),是Web联网的基础...

  • HTTP/HTTPS

    HTTP http协议属于明文传输协议,交互过程以及数据传输都没有进行加密,通信双方也没有进行任何认证,通信过程非...

  • HTTP、HTTPS

    WWW: WWW是一个基于HTTP的客户-服务器应用系统,即属于客户-服务器范型的分布式计算应用 HTTP协议: ...

网友评论

      本文标题:围绕HTTP、HTTPS、HTTP/2的进行的实践

      本文链接:https://www.haomeiwen.com/subject/lxhefctx.html