<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>https://carl-ds.github.io/</id>
    <title>Carl-DS</title>
    <updated>2020-01-08T11:36:47.969Z</updated>
    <generator>https://github.com/jpmonette/feed</generator>
    <link rel="alternate" href="https://carl-ds.github.io/"/>
    <link rel="self" href="https://carl-ds.github.io/atom.xml"/>
    <subtitle>温故而知新</subtitle>
    <logo>https://carl-ds.github.io/images/avatar.png</logo>
    <icon>https://carl-ds.github.io/favicon.ico</icon>
    <rights>All rights reserved 2020, Carl-DS</rights>
    <entry>
        <title type="html"><![CDATA[Nginx 配置 HTTPS 完整过程]]></title>
        <id>https://carl-ds.github.io/post/nginx-pei-zhi-https-wan-zheng-guo-cheng</id>
        <link href="https://carl-ds.github.io/post/nginx-pei-zhi-https-wan-zheng-guo-cheng">
        </link>
        <updated>2020-01-08T10:49:54.000Z</updated>
        <content type="html"><![CDATA[<h1 id="nginx-配置-https-完整过程">Nginx 配置 HTTPS 完整过程</h1>
<blockquote>
<p>使用SSL证书实现网站Https，防止数据遭窃取和篡改。<br>
说明: 以下操作过程是在使用yum安装nginx情况下进行的,或是二进制手动安装则相关目录可能不同</p>
</blockquote>
<h2 id="阿里云下载免费证书">阿里云下载免费证书</h2>
<ol>
<li>进入阿里云控制台搜索SSL =&gt; 点击[SSL证书(应用安全)]进入,然后点击[购买证书],如下:</li>
</ol>
<figure data-type="image" tabindex="1"><img src="https://tva1.sinaimg.cn/large/006tNbRwly1gapbd4pfrzj31910aqq3y.jpg" alt="image-20200108180804265" loading="lazy"></figure>
<p>这里选择免费版</p>
<figure data-type="image" tabindex="2"><img src="https://tva1.sinaimg.cn/large/006tNbRwly1gapblgcfefj31hb0p1gp1.jpg" alt="image-20200108181608837" loading="lazy"></figure>
<p>如果有多个域名,可以在购买数量外添加,省得麻烦再次购买。这里是免费0元，直接点击购买支付成功后，点击证书申请</p>
<figure data-type="image" tabindex="3"><img src="https://tva1.sinaimg.cn/large/006tNbRwly1gapbsizw4dj318w0h90ug.jpg" alt="image-20200108182259431" loading="lazy"></figure>
<p>然后补充信息，验证即可。成功后有消息通知再在SSL控制台已签发证书处下载所需服务器类型的证书，我们这里下载Nginx证书，之后将文件上传到服务器的 <code>/etc/nginx/</code> 解压重命名为 <code>cert</code></p>
<h2 id="修改nginxconf文件">修改nginx.conf文件</h2>
<pre><code class="language-shell">$ cd /etc/nginx
$ cp nginx.conf nginx.conf.bak
$ vim nginx.conf
</code></pre>
<h2 id="配置-https-server">配置 https server</h2>
<pre><code class="language-nginx">http {
		#将 http 重定向 https
		server {
        listen       80;
        server_name  www.baidu.com; #域名
        rewrite ^(.*)$ https://${server_name}$1 permanent; 
        
    }
    server {
    		#服务器端口使用443，开启ssl, 这里ssl就是上面安装的ssl模块
        listen       443 ssl;
        # 配置自己的域名，多个以空格分开
        server_name  baidu.com;

        #ssl证书地址
        ssl_certificate     /etc/nginx/cert/yourname.pem;  #pem文件的路径
        ssl_certificate_key  /etc/nginx/cert/yourname.key; # key文件的路径

        #ssl验证相关配置
        ssl_session_timeout  5m;    #缓存有效期
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;    #加密算法
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;    #安全链接可选的加密协议
        ssl_prefer_server_ciphers on;   #使用服务器端的首选算法

        location / {
            root   html;
            index  index.html index.htm;
        }

    }
}    
</code></pre>
<h2 id="重启-nginx">重启 nginx</h2>
<pre><code class="language-shell">$ systemctl reload nginx
</code></pre>
]]></content>
    </entry>
    <entry>
        <title type="html"><![CDATA[关于]]></title>
        <id>https://carl-ds.github.io/post/about</id>
        <link href="https://carl-ds.github.io/post/about">
        </link>
        <updated>2019-01-25T11:09:48.000Z</updated>
        <content type="html"><![CDATA[<p>这是关于的页面，可以在这里向世界介绍你！</p>
]]></content>
    </entry>
</feed>