问题描述
我正在尝试在我的ALB中创建规则,因此路径的某些部分没有转发到目标.因此,例如,我的基础服务可能会接受类似的呼叫
I am trying to create rules in my ALB so there are parts of the path that I do not forward on to the target. So for example, my underlying service may accept a call like
获取 http://主机名/狗
但是在ALB中,我可能会在路径中添加一个版本以进行路由:
But in the ALB I might add a version to the path for routing purposes:
或者我可以打电话
两个版本将在不同的目标组中运行.我当时想我可以删除版本部分,以便我的应用程序不必关心版本控制.但是,我如何处理它尚不明确,而且似乎也不可能.
Both versions would be running in different target groups. I was thinking I could then drop the version part off so that my application doesn't have to be concerned with versioning. However, it's not obvious how I might handle that and it doesn't appear to be possible.
推荐答案
Application Load Balancer当前不支持此功能.
This is not something that is currently supported by Application Load Balancer.
CloudFront的设置名为在请求URI之前添加到请求URI的原始路径(在本例中为原始ALB),因此如果需要,您可以将原始路径设置为/v1
example.com/dogs
将作为example.com/v1/dogs
发送到ALB. CloudFront是CDN,但它还有许多其他用途,例如请求重写-本质上是具有缓存的大规模分布在全球的反向代理,并支持动态和静态内容.除CloudFront外,更复杂的重写还需要Lambda @ Edge,但是在某些请求路径模式之前添加字符串是基本功能集的一部分.
CloudFront, however, has a setting called Origin Path that is prepended to the request URI before sending the request to the origin server -- in this case, the origin ALB -- so you'd set the origin path to /v1
if you wanted example.com/dogs
to be sent to the ALB as example.com/v1/dogs
. CloudFront is a CDN but it has a number of other purposes, such as request rewriting -- it's essentially a massive, globally-distributed reverse proxy with a cache, and supports dynamic as well as static content. More complex rewrites require Lambda@Edge in addition to CloudFront, but prepending a string to certain request path patterns is part of the base feature set.
这篇关于是否可以使用aws elb转发路径的仅一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!