吹静静

欢迎QQ交流:592590682

场景描述

现在有 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 项目即可。

 

posted on 2023-02-06 18:08  吹静静  阅读(325)  评论(0编辑  收藏  举报