一:前提

首先我们应该去华为云申请ssl证书,一般有单域名,泛域名,多域名的类型,我这边是单域名申请的。

二:下载证书

当我们申请好证书后,我们需要下载证书,到电脑本地。

三:配置ssl证书

配置ssl证书分为nginx配置,代码内部配置

首先nginx配置,这边在网上介绍也是很多列子。

1.我这边把证书位置放在服务器nginx目录下新建了一个文件夹存储,以下nginx配置

user  nobody;
worker_processes  1;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;server {listen       80;server_name  绑定ssl证书域名;rewrite ^(.*) https://$server_name$1 permanent;    #转https#charset koi8-r;#access_log  logs/host.access.log  main;#location / {#    root   /mnt/yilong/front/;#    index  index.html;#}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS serverserver {listen               443  ssl;server_name          绑定ssl证书域名;ssl_certificate      cert/证书名称.crt;ssl_certificate_key  cert/scs1617085487974_证书名称.key;ssl_session_cache    shared:SSL:1m;ssl_session_timeout  5m;ssl_protocols        TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers          ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;ssl_prefer_server_ciphers  on;location / {root   /mnt/yilong/front/;   #前端路径index  index.html;proxy_set_header Host $host;}   }}

2.代码内部配置

* 首页证书要拷贝到静态目录

* 根据地址我们可以配置到yml

server:port: 8081ssl:key-store: classpath:source/sslhttps.jkskey-store-password: 密码keyStoreType: 类型keyAlias: 名称

* 然后我们就可以在代码中实现ssl认证

//    @Bean
//    public ServletWebServerFactory servletContainer() {
//        TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
//            @Override
//            protected void postProcessContext(Context context) {
//                SecurityConstraint securityConstraint = new SecurityConstraint();
//                securityConstraint.setUserConstraint("CONFIDENTIAL");
//                SecurityCollection collection = new SecurityCollection();
//                collection.addPattern("/*");
//                securityConstraint.addCollection(collection);
//                context.addConstraint(securityConstraint);
//            }
//        };
//        tomcat.addAdditionalTomcatConnectors(initiateHttpConnector());
//        return tomcat;
//    }
//
//    private Connector initiateHttpConnector() {
//        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
//        connector.setScheme("http");
//        connector.setPort(8082);
//        connector.setSecure(false);
//        connector.setRedirectPort(8081);
//        return connector;
//    }

* 打包部署,验证是否带锁,访问需要https

SpringBoot项目部署到华为云ssl证书配置相关推荐

  1. 解决springboot项目部署到阿里云服务器邮箱无法发送邮件

    解决springboot项目部署到阿里云服务器邮箱无法发送邮件 前言:今天部署了一下springboot项目,使用的是docker部署的,如果有兴趣可以看我这篇文章: docker上部署前后端分离的s ...

  2. 华为云ssl证书申请和安装

    华为云ssl证书申请和安装 1.打开网站,点击领取免费证书,点击立即购买. 2.打开华为云控制台,找到云证书管理服务.确认付款后自动跳转,点击申请证书. 填写自己的域名. 填写授权人信息,姓名.电话. ...

  3. 保姆级教程——将springboot项目部署到阿里云服务器(小白包会)

    保姆级教程--将springboot项目部署到阿里云服务器(小白包会) 前言: 昨天本想着看论文,结果发现找的论文和课题不一致.那干点什么好呢?那就把我的毕业设计(一个springboot项目)部署到 ...

  4. 如何将SpringBoot项目部署到阿里云Linux服务器中

    在此之前,我写了一个如何购买阿里云Windows服务器,并将自己的SpringBoot项目部署到Windows云服务器的博客,链接如下:https://blog.csdn.net/MagicMHD/a ...

  5. 解决springboot项目部署到阿里云服务器邮箱无法发送邮件而本地可以问题(亲测有用)

    解决springboot项目部署到服务器邮箱无法发送邮件而本地可以问题(亲测有用) 前言: 由于SpringBoot项目有发送邮箱功能,但是部署到服务器上却出现无法发送问题!但是本地却可以!!大致看了 ...

  6. 阿里云ECS服务器购买及配置,SpringBoot项目部署到阿里云ECS服务器,阿里云ECS服务器安装JDK、Mysql、nginx详细步骤

    1.购买阿里云ECS服务器 官网:阿里云-上云就上阿里云 根据自己的需要选择相应的配置: 目前有一个月的服务器免费体验时间,我选择了免费体验,点击后,可以看到你刚才购买的服务器: 也可以通过这里查看你 ...

  7. 将Web项目部署到华为云服务器的Linux的Tomcat中

    将Web项目部署到阿里云服务器的Linux的Tomcat中 01_用SSH Secure Shell Client或Xshell 6这个Windows客户端工具,将在Windows中已经开发完毕的Ja ...

  8. windows系统下,Apache安装腾讯云SSL证书配置教程(phpstudy环境)

    第1步.登录腾讯云申请SSL证书并下载,这里省略申请的步骤. 第2步.解压证书文件,打开Apache文件夹,里面有三个文件,如下: 1_root_bundle.crt // 公钥 2_www.cpw5 ...

  9. 华为云mysql认证ssl_华为云SSL证书

    华为云文档数据库服务工具,其实这就是华为云的一个SSL证书,主要用来防止欺诈攻击,它可以将数据库实例终端节点的IP作为SSL证书的公用名,而且还带有加密,大大提高了数据在网络传输过程中的安全性,是您首 ...

最新文章

  1. centos7下docker1.12.5学习笔记
  2. 周期性定时事件的处理
  3. 百度产品经理vs 腾讯产品经理:技术大牛与小白
  4. 【Cli下在vue.config.js配置configureWebpack/resolve/alias之无效 - 】
  5. java se环境变量_Windows 7中配置JDK(Java SE)环境变量
  6. java 动态增加线程,java - 在Java中动态停止线程 - SO中文参考 - www.soinside.com
  7. sysbench0.5 mysql_sysbench 0.5安装步骤
  8. git remote传到远程
  9. Java基础笔记(三)
  10. python颜色校正
  11. java 7下载地址
  12. 好用的项目工时管理系统有哪些
  13. dubbo源码编译(顶)
  14. 最有效地戒掉晚睡强迫症(熬夜强迫症、假象失眠症等等)
  15. 模式识别和计算机科学与技术,模式识别与智能系统
  16. CSS 单(多)行文本超过部分显示省略号,解决数字或英文不换行问题
  17. vue复选框组件自定义对勾_关于vue的列表图片选中打钩操作
  18. 看了几个技术入股的帖子,忍不住写个自己亲身经历吧
  19. eclipse IED的优化(gc.log)
  20. matlab中removeback的意思,remove是什么意思

热门文章

  1. 下辈子如果我还记得你!!!
  2. 普中科技51纯代码(按键)
  3. java实现百度站长主动推送个人网站链接
  4. c语言strtok2个字符连在一起,在C中使用strtok使用多个分隔符的分割字符串
  5. el-upload 上传压缩图片
  6. 彼岸花的传说——附三色彼岸花图
  7. 网络文学2.0时代 网络文学与传统文学究竟应该如何融合?
  8. java installanywhere_InstallShield InstallAnywhere 培训要点记录(一)
  9. 人工智能可以取代人类思维吗?
  10. Linux下EMQ X的安装和配置