网站升级HTTPS教程
现在越来越多的网站开始使用https协议,其实百度从2014年底就已经开始支持https了,并且据说在排名上,同权重的网站,开启https会优待提升排名。先不管排不排名吧,https是一种更安全更先进的技术。作为互联网的弄潮儿,我们必须要与时俱进呀~果断的,全站启用https协议。 不要以为开启https只是在网址http后面加个s就可以了,其实不是的。https是需要验证SSL证书的,如果没有证书或者证书不匹配,则通过https访问你的网站是会被浏览器拦截的。 一、获取证书 升级到 HTTPS 协议的第一步,就是要获得一张证书。阿里云上可以申请免费的HTTPS证书。 1.首先登录阿里云,在“产品与服务”的下拉菜单中,找到“CA证书服务(数据安全)”。 2.点击右上角“购买证书”按钮 3.“保护类型”选择“一个域名”,品牌选择赛门铁克。 然后证书类型选择“免费型DV SSL”。 4.点击“立即购买” 5.购买成功后,点击“补全” 6.输入一个域名,有一点需要注意,这里需要精确到二级域名,例如和pay.dedemao.com是两个二级域名,是不一样的。只能输入一个,如果有多个域名需要HTTPS,需要购买多次,每次配置一个域名。填写后,点击下一步。 7.填写个人信息,如果域名也在阿里云,域名验证类型可以选择DNS,并勾选。如果域名不在阿里云且服务器是linux的,那么选择文件。 8.如果是选择文件,需要将指定文件下载到指定目录下。 9.等待审核通过后,点击“下载”,下载证书。 二、安装证书 根据服务器的环境选择相应的证书下载并阅读配置教程即可。 安装成功后,使用SSL Labs Server Test 检查一下证书是否生效。 补充一下: 腾讯云面板下载的SSL证书压缩包里面包含各种服务器引擎的证书,你需要选择你的服务器类型比如我们用的是Nginx服务器,就需要上传Nginx专用的SSL证书。如果是IIS,就上传IIS专用的 服务器虚拟主机设置SSL证书路径 server { listen 80; root /www/web/idedecms_com/public_html; server_name idedecms.com idedecms.com img.idedecms.mysitecdn.com; index index.html index.php index.htm; error_page 400 /errpage/400.html; error_page 403 /errpage/403.html; error_page 404 /errpage/404.html; error_page 503 /errpage/503.html; location ~ .php$ { proxy_pass :88; include naproxy.conf; } location ~ /.ht { deny all; } location / { try_files $uri @apache; } location @apache { proxy_pass :88; include naproxy.conf; } return 301 https://www.$server_name$request_uri; } server { listen 443 ssl; root /www/web/idedecms_com/public_html; server_name idedecms.com idedecms.com img.idedecms.mysitecdn.com; index index.html index.php index.htm; error_page 400 /errpage/400.html; error_page 403 /errpage/403.html; error_page 404 /errpage/404.html; error_page 503 /errpage/503.html; location ~ .php$ { proxy_pass :88; include naproxy.conf; } location ~ /.ht { deny all; } location / { try_files $uri @apache; } location @apache { proxy_pass :88; include naproxy.conf; } ssl_certificate /www/ssl/idedecms_com/1_; ssl_certificate_key /www/ssl/idedecms_com/2_; ssl_session_timeout 5m; } 三、修改链接 下一步,网页加载的 HTTP 资源,网站页面js,css,以及图片资源引用地址改为https。因为加密网页内如果有非加密的资源,浏览器是不会加载那些资源的。 <script src=http://www.jb51.net/yunying/"http:/foo.com/jquery.js"></script> 其中,改法二会根据当前网页的协议,加载相同协议的外部资源,更灵活一些。 <link rel="canonical" href=http://www.jb51.net/yunying/"https:/foo.com/bar.html" /> (编辑:焦作站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |