springboot+nginx+https+linux实现负载均衡加域名访问简单测试
作者:偶尔晴天 时间:2022-04-26 22:35:13
1.把springboot项目打包成三个jar包,并指定端口为
14341,14342,14343
2.下载腾讯云免费ssl证书,解压后会出现如下图文件夹
3.把nginx文件夹下的 .crt 和 .key文件复制到服务器,例如复制到
/home/ssl/xxx.crt
/home/ssl/xxx.key
4.安装好nginx默认配置文件在
/usr/local/nginx/conf/nginx.conf
5.修改nginx.conf配置文件实现https+负载均衡的简单测试(此测试是在一台服务器上面进行)
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream paint {
server 127.0.0.1:14341 weight=2;
server 127.0.0.1:14342 weight=1;
server 127.0.0.1:14343 weight=1;
}
server {
listen 443 ssl;
server_name www.xxx.com xxx.com;
ssl_certificate /home/ssl/xxx.crt;
ssl_certificate_key /home/ssl/xxx.key;
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 / {
proxy_pass http://paint;
}
}
server {
listen 80;
server_name www.xxx.com xxx.com;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}
}
6.以上nginx.conf配置文件即可实现,理论上来说weight设置的数值越大,访问到的机率就会越大
总结
以上所述是小编给大家介绍的springboot+nginx+https+linux实现负载均衡加域名访问简单测试,网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
来源:https://www.cnblogs.com/b516/archive/2019/05/24/10916522.html
标签:spring,boot,负载均衡
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java Hibernate使用SessionFactory创建Session案例详解
2022-03-04 06:21:28
Android中AsyncTask与handler用法实例分析
2023-12-04 00:01:52
![](https://img.aspxhome.com/file/2023/8/88128_0s.png)
Java抽象类、继承及多态和适配器的实现代码
2021-07-14 05:38:00
SpringMVC Restful风格与中文乱码问题解决方案介绍
2021-06-12 03:15:16
![](https://img.aspxhome.com/file/2023/8/79908_0s.png)
Spring Boot 集成 Sharding-JDBC + Mybatis-Plus 实现分库分表功能
2023-08-28 16:52:09
![](https://img.aspxhome.com/file/2023/7/58277_0s.jpg)
java自定义ClassLoader加载指定的class文件操作
2022-03-16 16:19:07
![](https://img.aspxhome.com/file/2023/8/60848_0s.jpg)
解决运行jar包出错:ClassNotFoundException问题
2021-09-09 04:58:41
![](https://img.aspxhome.com/file/2023/6/75416_0s.png)
Java 字符终端上获取输入三种的方式分享
2021-12-31 04:52:45
Java手动实现Redis的LRU缓存机制
2023-07-31 12:51:30
![](https://img.aspxhome.com/file/2023/7/57807_0s.png)
轻量级声明式的Http库——Feign的独立使用
2022-06-05 04:36:19
java多次嵌套循环查询数据库导致代码中数据处理慢的解决
2023-10-28 22:17:50
Java实现月饼的制作、下单和售卖功能
2023-03-06 18:26:24
![](https://img.aspxhome.com/file/2023/4/85574_0s.png)
Java流程控制顺序结构原理解析
2022-09-13 14:14:03
![](https://img.aspxhome.com/file/2023/1/79311_0s.png)
java金钱处理方法实例详解
2023-05-29 10:38:29
java实习--每天打卡十道面试题!
2021-12-06 15:22:19
![](https://img.aspxhome.com/file/2023/2/85522_0s.png)
详解APP微信支付(java后台_统一下单和回调)
2023-11-10 17:26:42
![](https://img.aspxhome.com/file/2023/3/59153_0s.png)
Java数据结构之栈与队列实例详解
2021-05-29 03:25:13
![](https://img.aspxhome.com/file/2023/1/61591_0s.png)
详解android是如何管理内存的
2022-02-08 03:37:22
![](https://img.aspxhome.com/file/2023/8/87308_0s.png)
流读取导致StringBuilder.toString()乱码的问题及解决
2022-12-20 13:34:14
JVM之方法返回地址详解
2022-05-02 07:58:27
![](https://img.aspxhome.com/file/2023/0/88590_0s.png)