NGINX
大约 2 分钟
NGINX
感性体验下负载均衡配置
- 本地启动两个jetty
要达到的效果:通过nginx开启80端口,在浏览通过localhost来访问jetttyA 和 jettyB 提供的服务。
jettyA localhsot:6000 首页输出:6000
jettyB localhsot:7000 首页输出:7000
- 进入nginx配置文件目录
cd /etc/nginx
- 修改 nginx.conf
在http节点下新增如下配置:
upstream lyzc {
ip_hash;
server localhost:6000;
server localhost:7000;
}
这个配置即为负载均衡的配置,但现在还没有使用。
lyzc :对集群的命名,可以为域名,名称自己确定
ip_hash : 负载均衡算法,可以不写(不写的情况默认为轮询算法)
server : 配置提供服务的机器节点信息,可以任意多个
然后在server节点下,修改或添加location的配置如下:
location / {
proxy_pass http://lyzc;
}
安装nginx
yum install nginx
配置文件在 /etc/nginx目录
cd /etc/nginx
cp nginx.conf nginx.conf.bak
修改 nginx.conf 文件:参考其他配置
系统推荐
- MySQL杂项
- CloudFlare 客户端证书的使用
- 测试两台服务器间的网速
- Thread & ExecutorService & ThreadPoolExecutor 总览
- MAC CMS
- ShadowsockServerUpdatePort
- istio基础知识
- MySQL索引
- Markdown软件比对
- RocketMQ
- SpringBoot服务在服务启动完成前被提前注册到nacos
- 分布式问题
- 随机毒鸡汤:饿了不知道吃什么,想吃点爱情的苦。