创建 AWS 应用程序负载均衡器规则,无需使用额外的反向代理(如 nginx、httpd)即可修剪请求的前缀 [英] Create AWS Application Load Balancer Rule which trim off request's prefix without using additional reverse proxy like nginx, httpd

查看:28
本文介绍了创建 AWS 应用程序负载均衡器规则,无需使用额外的反向代理(如 nginx、httpd)即可修剪请求的前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我有几个服务.我想将带有前缀/secured"的每个请求转发到 server1 端口 80,并将所有其他请求转发到服务器 2 端口 80.问题是在 server1 上,我正在运行接受没有/secured"前缀的请求的服务.换句话说,我想转发每个请求,例如http://example.com/secured/api/getUser" 作为 "http://example.com/api/getUser" (从请求路径中删除/secured).

Basically, I have a couple of services. I want to forward every requests with prefix "/secured" to server1 port 80 and all other requests to server 2 port 80. The problem is that on server1, I am running service which accept the request without "/secured" prefix. In other words, I want to forward every requests such as "http://example.com/secured/api/getUser" to server1 as "http://example.com/api/getUser" (remove /secured from request' path).

使用 AWS ALB,当前请求作为 http://example.com/secured/api/发送获取用户;这迫使我更新我的 server1 的代码,以便代码处理带有/secured 前缀的请求,这看起来不太好.

With AWS ALB, currently the request is sent as http://example.com/secured/api/getUser; which forces me to update my server1's code so that the code handles requests with /secured prefix which doesn't look good.

有没有什么简单的方法可以用 ALB 解决这个问题?

Is there any easy way to solve this with ALB?

谢谢.

推荐答案

我可以确认,很遗憾,仅靠 ALB 无法做到这一点 - 我同意它确实应该如此.

I can confirm that this is unfortunately not possible with the ALB alone - and I agree it really should be.

AWS 声明:

请注意,路径模式用于路由请求但不改变它们.例如,如果规则的路径模式为/img/*,则规则会将/img/picture.jpg 的请求转发到指定的目标群体作为/img/picture.jpg 的请求.

Note that the path pattern is used to route requests but does not alter them. For example, if a rule has a path pattern of /img/*, the rule would forward a request for /img/picture.jpg to the specified target group as a request for /img/picture.jpg.

这篇关于创建 AWS 应用程序负载均衡器规则,无需使用额外的反向代理(如 nginx、httpd)即可修剪请求的前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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