Nginx 做jar包访问的负载均衡 您所在的位置:网站首页 nginx代理jar包 Nginx 做jar包访问的负载均衡

Nginx 做jar包访问的负载均衡

#Nginx 做jar包访问的负载均衡| 来源: 网络整理| 查看: 265

Nginx 做jar包访问的负载均衡 原创

wx5a099c852309b 2023-05-21 01:34:50 ©著作权

文章标签 Nginx nginx jar vim 文章分类 HarmonyOS 后端开发

©著作权归作者所有:来自51CTO博客作者wx5a099c852309b的原创作品,请联系作者获取转载授权,否则将追究法律责任 场景描述

现在有 jar_1、jar_2 两个项目, 3个bigdata服务器节点,

jar_1 部署在bigdata1节点,jar_2 部署在3个节点,

用户访问 jar_1,jar_1 将访问请求转发给3个节点上的 jar_2。

jar_2 的监听端口 50544。

配置调试

1.修改nginx.conf

vim /etc/nginx.conf

# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$host" "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 4096; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; }

nginx.conf

2.添加calc.bigdata.com.conf

vim cd /etc/nginx/conf.d/calc.bigdata.com.conf

upstream calc { server bigdata1:50544; server bigdata2:50544; server bigdata3:50544; } server { server_name calc.bigdata.com; listen 30543; location / { proxy_pass http://calc; } }

3.修改bigdata1的hosts文件,添加如下内容:

127.0.0.1        calc.msun.com

4.重启Nginx

nginx -s reload

访问  jar_1 项目即可。

 

收藏 评论 分享 举报

上一篇:查询Postgres数据库中每个表的数据量大小



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有