多个页面的 HTTP 网关

发布于 2024-11-27 22:16:37 字数 735 浏览 0 评论 0原文

我们正在开发一个网关服务器,它将作为多个网页的入口点。可以通过 http://example.com 访问网关,并且路由到的每个网页都有一个唯一的 URL,例如http://example.com/app1 将带您前往 app1。应用程序app1位于某个内部服务器,例如http://app1.internal,并且是只能通过网关对外访问。

网关不会向用户发送 302 重定向,而是从 app1 获取内容并将其提供给位于 http://example.com/app1。我们无法编辑app1的源代码,因此必须有某种机制来重写URL,即/images/image1.jpg变成/app1/images/image1.jpg。

这适用于图像和静态内容,但不适用于嵌入某些元素属性中的 javascript、css 和 URL 等。目前,我们为每种情况创建特殊代码。

所以,我正在寻找一些更好的方法来解决这个问题。也许有一些软件具有这样的功能?或者某种方式来标记来自页面的每个请求?欢迎所有想法。

提前致谢!

We are working on a gateway server that would serve as an entry point for multiple web pages. The gateway is accessible at http://example.com and every web page that is routed to has a unique URL, for instance http://example.com/app1 will take you to app1. Application app1 is located at some internal server, say http://app1.internal, and is available to outside only through the gateway.

The gateway doesn't send a 302 redirect to user, but instead fetches the content from app1 and serves it to the user at http://example.com/app1. We cannot edit the source code of app1, so there must be some mechanism to rewrite URLs, i.e. /images/image1.jpg becomes /app1/images/image1.jpg.

This works well with images and static content, but doesn't work with javascript, css and URLs that are embedded in some element attributes, etc. Currently we create special code for every such case.

So, I am looking for some better way to solve this problem. Maybe there is some software which has such functionality? Or some way to tag every request coming from a page? All ideas are welcomed.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随心而道 2024-12-04 22:16:37

听起来您正在寻找的是反向代理,其中有很多选项。

It kind of sounds like what you're looking for is a reverse proxy, of which there are many options.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文