配置负载均衡器以路由到实例的不同页面? [英] Configuring Load Balancer to Route to different pages of instance?

查看:87
本文介绍了配置负载均衡器以路由到实例的不同页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我在实例x的前面有一个AWS负载均衡器.
  • 实例x在以下位置运行 端口3000.实例x有两个页面,即x/abc和x/zyx.
  • 当前x的负载均衡器有两个侦听器,即80 -> 30008080 -> 3000.然后在/
  • 上执行ping操作
  • I have an AWS load Balancer in front of instance x.
  • Instance x runs on port 3000. Instance x has two pages i.e. x/abc and x/zyx.
  • Currently the load balancer of x has two listeners i.e. 80 -> 3000 and 8080 -> 3000. And ping on /

要求:我有两个要与实例x通信的服务器.服务器1希望将http请求发送到x/abc和服务器2 想要将http请求发送到x/zyx.

Requirement: I has two servers that want to communicate to instance x. Server 1 wants to send http request to x/abc and server 2 wants to send http request to x/zyx.

如何配置LB路由到特定页面,例如x/abc和x/zyx? 还是以其他方式编写我的请求?

代码1:服务器1要向x/abc发出http请求

// url is the DNS of load balancer... this should go to x/abc(?)
request({
    url: "LoadBalancer-11122232.us-west-2.elb.amazonaws.com:80",
    method: "POST",
    json: true,  
    body: tweetJSON
}

代码2:服务器2希望向x/zyx发出http请求

// url is the DNS of load balancer... this should go to x/abc 
// DO I EVEN NEED TWO DIFFERENT PORT LISTENERS(?)
    request({
        url: "LoadBalancer-11122232.us-west-2.elb.amazonaws.com:8080",
        method: "POST",
        json: true,  
        body: tweetJSON
    }

推荐答案

您没有将负载均衡器配置为将请求路由到不同的端点,这更像是反向代理的工作,例如

You don't configure the Load Balancer to route requests to different endpoints, that's more the job of a reverse proxy, like Nginx.

Load Balancer提供一个要调用的端点,并将来自客户端的请求转发到许多相同服务器之一.其目标是在许多服务器之间共享高负载.

The Load Balancer provides a single endpoint to call, and forwards requests from clients to one of many identical servers. The objective it to share high loads across many servers.

在您所处的环境中,您仍然可以使用负载均衡器,但就路由而言,我建议您完整输入URL:

In your situation, you can still have a Load Balancer in the mix, but as far as routing I suggest that you address the URL in full:

代码1:服务器1要向x/abc发出http请求

Code 1: Server 1 wants to make http request to x/abc

// url is the DNS of load balancer plus the route (/abc)
request({
    url: "https://LoadBalancer-11122232.us-west-2.elb.amazonaws.com/abc",
    method: "POST",
    json: true,  
    body: tweetJSON
}

代码2:服务器2希望向x/zyx发出http请求

Code 2: Server 2 wants to make http request to x/zyx

// url is the DNS of load balancer plus the route (/zyx)
request({
    url: "https://LoadBalancer-11122232.us-west-2.elb.amazonaws.com/zyx",
    method: "POST",
    json: true,  
    body: tweetJSON
}

如果您需要阻止客户端访问后端URL,则需要某种形式的身份验证来标识服务器2.

If you need to prevent clients going to the backend url, you need some form of authentication to identify server 2.

这篇关于配置负载均衡器以路由到实例的不同页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆