如何告诉AWS应用程序负载平衡器不转发路径模式? [英] How to tell AWS application load balancer to not forward the path pattern?

查看:76
本文介绍了如何告诉AWS应用程序负载平衡器不转发路径模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将AWS应用程序负载均衡器配置为具有以下规则:

I have configured my AWS application load balancer to have the following rules:

  • /images/*转发到服务器A(https://servera.com)
  • /videos/*转发到服务器B(https://serverb.com)
  • /images/* forward to server A (https://servera.com)
  • /videos/* forward to server B (https://serverb.com)

这正确地转发到各个服务器.但是,我不希望负载平衡器将请求转发为https://servera.com/images& https://serverb.com/videos.我只希望在不使用https://servera.com& https://serverb.com(请求中没有路径模式).

And this is correctly forwarding to the respective servers. However, I don't want the load balancer to forward the request as https://servera.com/images & https://serverb.com/videos. I just want the respective servers to be hit without the path pattern as https://servera.com & https://serverb.com (without the path patterns in the request).

我不想为此修改请求参数或服务器端代码.有没有办法让我告诉应用程序负载平衡器不转发路径模式?

I don't want to modify my request parameters or change my server side code for this. Is there a way I can tell the application load balancer to not forward the path patterns?

推荐答案

有没有办法告诉应用程序负载平衡器不转发路径模式?

Is there a way I can tell the application load balancer to not forward the path patterns?

不,没有.它使用模式来匹配请求,但不会修改请求.

No, there isn't. It's using the pattern to match the request, but it doesn't modify the request.

我不想为此修改请求参数或服务器端代码.

I don't want to modify my request parameters or change my server side code for this.

您必须更改某些内容.

您不必更改实际的代码.如果您确实需要此行为,则应该能够使用网络服务器 configuration 完成此操作.在Web服务器将请求移交给应用程序之前,内部路径重写应该是Nginx,Apache,HAProxy或实际在实例上进行监听的相对琐碎的重新配置.

You shouldn't have to change your actual code. If you really need this behavior, you should be able to accomplish it using the web server configuration -- an internal path rewrite before the request is handed off to the application by the web server should be a relatively trivial reconfigurarion in Nginx, Apache, HAProxy, or whatever is actually listening on the instances.

另外,在我看来,您希望服务器响应与浏览器所请求的路径不同的路径,这使您自己变得很困难.这样的配置将使确保正确的测试结果以及正确地相对和绝对路径的处理变得更加困难,因为应用程序将对浏览器正在请求或将要请求的内容进行不正确的内部表示.

Also, it seems to me that you are making things difficult on yourself by wanting the server to respond to a path different than what is requested by the browser. Such a configuration will tend to make it more difficult to ensure correct test results and correct handling of relative and absolute paths, since the applications will have an inaccurate internal representation of what the browser is requesting or will need to request.

这篇关于如何告诉AWS应用程序负载平衡器不转发路径模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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