AWS ELB 重写路径并更改其间的路径 [英] AWS ELB rewrite path and alter the path in between

查看:25
本文介绍了AWS ELB 重写路径并更改其间的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Amazon Webservices(特别是应用程序负载均衡器)上使用 ELB(弹性负载均衡器).

I'm using an ELB (Elastic Load Balancer) on Amazon Webservices (spezifically an Application Load Balancer).

问题:我想创建一个规则来重写路径,但需要在路径中插入一个字符串.

The Problem: I want to create a rule to rewrite the path, but need to insert a string within the path.

当请求进入时:

example.org/api/foo/*

我需要将其重定向到:

example.org/api/v1/foo/*

请求的其余部分需要保持不变.问题是路径的原始值不能改变.原因的一种方法是将所有可能的路径添加为规则.但是在扩展api时会非常不舒服.

The rest of the request needs to stay the same. The problem is that the original value of path cannot be altered. One way of cause would be to add every possible path as a rule. But when expanding the api it would be extremly uncomfortable.

推荐答案

正如您已经发现的那样,ELB 不支持重写.

Rewriting is not supported by the ELB as you already discovered.

一些选项:

1) 实现一个网络服务器,例如ALB和你的应用之间的nginx,可以实现重写规则

1) Implement a webserver e.g. nginx between the ALB and your application, which can implement rewrite rules

2) 使用Route53 -> 可以实现基于路径的重写.CloudFront ->拉姆达 ->ALB,而不是直接Route53 ->ALB,如here.

2) Path-based rewriting can be achieved by using Route53 -> CloudFront -> Lambda -> ALB, instead of straight up Route53 -> ALB, as demonstrated here.

这篇关于AWS ELB 重写路径并更改其间的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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