编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

https安装证书方法(https安全证书下载)

wxchong 2024-09-07 21:08:32 开源技术 26 ℃ 0 评论

根据服务器的环境选择相应的证书下载并阅读配置教程即可。

安装成功后,使用SSL Labs Server Test 检查一下证书是否生效。

补充一下:

腾讯云面板下载的SSL证书压缩包里面包含各种服务器引擎的证书,你需要选择你的服务器类型比如我们用的是Nginx服务器,就需要上传Nginx专用的SSL证书。如果是IIS,就上传IIS专用的

服务器虚拟主机设置SSL证书路径

上传了SSL证书之后,我们还需在虚拟主机配置文件里面指定一下SSL证书的路径,不然访问会出错。

别的服务器我们并不了解。但是就我们现在用的WDCP面板+Nginx配置文件的写法是。你需要先找到

你服务器虚拟主机配置文件的路径,我们的是/conf/vhost/idedecms.com.conf各有不同,举一反三。

server {
 listen 80;
 root /www/web/idedecms_com/public_html;
 server_name idedecms.com idedecms.com www.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 http://127.0.0.1:88;
 include naproxy.conf;
 }
 location ~ /\.ht {
 deny all;
 }
 location / {
 try_files $uri @apache;
 }
 location @apache {
 proxy_pass http://127.0.0.1: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 www.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 http://127.0.0.1:88;
 include naproxy.conf;
 }
 location ~ /\.ht {
 deny all;
 }
 location / {
 try_files $uri @apache;
 }
 location @apache {
 proxy_pass http://127.0.0.1:88;
 include naproxy.conf;
 }
ssl_certificate /www/ssl/idedecms_com/1_www.idedecms.com_bundle.crt;
ssl_certificate_key /www/ssl/idedecms_com/2_www.idedecms.com.key;
ssl_session_timeout 5m;
}

三、修改链接

下一步,网页加载的 HTTP 资源,网站页面js,css,以及图片资源引用地址改为https。因为加密网页内如果有非加密的资源,浏览器是不会加载那些资源的。

<script src="http://foo.com/jquery.js"></script>

上面这行加载命令,有两种改法。

<!-- 改法一 -->

< script src="https://foo.com/jquery.js"></script>

< !-- 改法二 -->

< script src="//foo.com/jquery.js"></script>

其中,改法二会根据当前网页的协议,加载相同协议的外部资源,更灵活一些。

另外,如果页面头部用到了rel="canonical",也要改成HTTPS网址。

<link rel="canonical" href="https://foo.com/bar.html" />

这个不用我说了吧,网站开启https之后,页面上使用http调用的资源都会无法调用。你需要把http的资源全都改成https调用。记住,不能漏掉任何一个js引用或者图片如果有一个文件不是https引用的,则你的网站虽然可以正常https访问,但是地址栏的https标识不会完全变绿,360浏览器尤为明显。这代表你网站虽然启用了https但是没有做到完全的规范。被认定为不规范的https页面。

四、301重定向

下一步,修改 Web 服务器的配置文件,使用 301 重定向,将 HTTP 协议的访问导向 HTTPS 协议。

Nginx 的写法。

server {
 listen 80;
 server_name domain.com www.domain.com;
 return 301 https://domain.com$request_uri;
}

Apache 的写法(.htaccess文件)。

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表