« 上一篇下一篇 »

Safari浏览器访问会显示"不安全"解决方法-安装ssl证书配置https

      最近在帮朋友弄一个自己的网站,配置好域名与站点之后,用苹果的Safari浏览器访问会显示"不安全",强迫症迫使我要将网站的http访问换成https访问。

      nginx配置https访问并不难,分为两个步骤:首先,你需要准备网站域名的SSL安全证书(crt文件和key文件),我的域名是腾讯云的,所以直接想腾讯云申请ssl证书就可以了,审核通过之后就可以在腾讯云上下载ssl证书。其次,有了证书之后就需要配置nginx服务器的nginx.conf就可以了。具体操作如下:

       1.将下载的证书解压,复制nginx目录下的crt文件和key文件到nginx.conf同级目录下。

       2.在nginx.conf中如下配置:

server {
 listen       443;
    server_name  127.0.0.1 alias localhost; #也可以换成你的域名
    ssl                  on;
    ssl_certificate      1.crt;    #拷贝过来的crt文件
    ssl_certificate_key  2.key;    #拷贝过来的ket文件
    ssl_session_timeout  5m;
    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;
    location / {
    root   Z:/phpApp/vaeFamily/public;  #网站站点目录
    index  index.html index.htm;

 location / {
            root   Z:/phpApp/vaeFamily/public;  #网站站点目录
            index  index.html index.htm default.html default.htm index.php default.php app.php u.php;
   include        Z:/phpApp/UPUPW_NP7.0/htdocs/up-*.conf;
 
        location ~ ^.+\.php {
            root           Z:/phpApp/vaeFamily/public; 网站站点目录
            fastcgi_pass   bakend;
            fastcgi_index  index.php;
   fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
   fastcgi_param  PATH_INFO $fastcgi_path_info;
   fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_path_info;
            include        fastcgi.conf;
 server {
    listen 80;
    server_name 127.0.0.1;
    rewrite ^(.*)$ https://$host$1 permanent;  #配置http自动跳转https
}
        3.配置好之后保存然后测试一下:

 

       4.保存配置文件重启nginx

 

 最后打开你的站点,看到绿色的小锁和https就代表已经成功了!

 还有就是如果你的网站引入了外部资源是http协议比如cdn加速的js等,要换成https才能有效引入。