峨影夜思 發表於 2020-9-16 13:59:00

nginx 配置域名https访问

<h1>一、获取https证书,以阿里云为例</h1>
<h2>  1.进入域名解析,添加一个域名,详细过程略</h2>
<p>  <img src="https://img2020.cnblogs.com/blog/2138963/202009/2138963-20200916105918265-1563603687.png"></p>
<h2>&nbsp; &nbsp; &nbsp;&nbsp; 2.购买免费版ssl证书,购买完之后,填写域名信息</h2>
<p>  <img src="https://img2020.cnblogs.com/blog/2138963/202009/2138963-20200916110136419-1604139565.png"></p>
<p>&nbsp; &nbsp; &nbsp;&nbsp;</p>
<p>&nbsp; &nbsp; &nbsp;&nbsp; <img src="https://img2020.cnblogs.com/blog/2138963/202009/2138963-20200916133933181-1112154488.png"></p>
<h2>&nbsp; &nbsp; &nbsp;&nbsp; 3.待审核通过,下载ssl证书</h2>
<p>&nbsp; &nbsp; &nbsp; &nbsp;<img src="https://img2020.cnblogs.com/blog/2138963/202009/2138963-20200916134606436-1041030058.png"></p>
<h1>二、linux 部署</h1>
<h2>  1. 新建一个文件夹,放上面下载后的压缩包,并解压,解压后为两个文件key和pem</h2>
<p>  <img src="https://img2020.cnblogs.com/blog/2138963/202009/2138963-20200916135055056-1146828366.png"></p>
<h2>&nbsp; &nbsp; &nbsp;&nbsp; 2.修改linux配置文件,并重启</h2>
<p>  </p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">server{

      #listen       80;<br>#需替换
      server_name XXX.com;
      
      listen443 ssl;
      ssl                  on;
      #public key<br>#需替换
      ssl_certificate      /webapp/cert/business/XXX.com.pem;
      #private key<br>#需替换
      ssl_certificate_key   /webapp/cert/business/XXX.com.key;

      ssl_session_timeout5m;

      ssl_protocolsTLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphersECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
      ssl_prefer_server_ciphers   on;

      #wap
      location / {

                if ($http_user_agent = ""){
               return 403;
                }
                if ($http_user_agent = "-"){
                              return 403;
                         }
                trim on;
                trim_js on;
                trim_css on;<br>   #需替换
                proxy_pass http://XXX:8192;
                proxy_buffering on;
                index index.jsp index.htmindex.html ;
                proxy_redirect default ;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                add_header Content-Type "application/json;charset=utf-8";
                client_max_body_size 70m;
      }
                  

}<br><br><br><br></span></pre>
</div>
<p>重启!完毕!</p>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/leva/p/13678758.html
頁: [1]
查看完整版本: nginx 配置域名https访问