Is it possible to forward only part of a path using aws elb?

时光怂恿深爱的人放手 提交于 2019-12-24 21:19:15

问题


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

GET http://hostname/dogs

But in the ALB I might add a version to the path for routing purposes:

GET http://hostname/v1/dogs

or I could call

GET http://hostname/v2/dogs

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.


回答1:


This is not something that is currently supported by Application Load Balancer.

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.



来源:https://stackoverflow.com/questions/47667372/is-it-possible-to-forward-only-part-of-a-path-using-aws-elb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!