ASP.Net反向代理,如何处理外部资源?
我目前正在研究反向代理的概念,以基本上在用户和其他不可见的网站之间中继响应和请求。因此,基本上用户会访问一个网站,比如说 www.myproxyportal.com,在这里可以访问网络服务器 Intranet 中未公开的网站(例如,internal.myproxyportal.com)(在 iframe 中)。
我一直在研究一种解决方案,将请求对象转换到所需位置并将响应返回到网站。效果很好,除了 CSS 链接、IMG 等之外。我当然可以进行翻译,但链接会转到internal.myproxyportal.com/css/style.css,这从外部永远不会起作用。
如何处理这样的事情?
也许有任何开箱即用的解决方案吗?
编辑:我发现 this,这与我所拥有的非常相似到目前为止已经写好了,但它还缺乏对外部图像、css、javascript 等的支持。
I'm currently working on a concept for a reverse proxy to basically relay responses and requests between the user and an otherwise invisible website. So basically the user goes to a site, let's say www.myproxyportal.com, where it is possible to access a website (in an iframe) in the webserver's intranet which isn't made public (for example internal.myproxyportal.com).
I've been working on a solution where I translate request objects to the desired location and return that response to the website. Works great, except for stuff like CSS links, IMG's, etc. I can do the translation of course, but then the link would go to internal.myproxyportal.com/css/style.css and this will never work from the outside.
How to approach such a thing?
Are there any out of the box solutions maybe?
EDIT: I found this, which is very similar to what I have written so far, but it also lacks support for external images, css, javascript, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以更改 IIS 中的设置以通过 ASP.NET 管道路由所有请求,而不仅仅是 .aspx 页面。然后只需创建一个 HttpHandler 来处理代理中的那些。
默认情况下,IIS 不通过 ASP.NET 引擎运行“静态”内容请求。
You can change settings in IIS to route all requests through ASP.NET pipeline, not just .aspx pages. Then simply create an HttpHandler to handle those in your proxy.
By default, IIS doesn't run "static" content requests through ASP.NET engine.
Apache 有一个非常灵活的内置反向代理,我广泛使用它。
在此处查看更多信息:http://www.apachetutor.org/admin/reverseproxies
Apache has a pretty slick reverse proxy built-in, I use it extensively.
See more here: http://www.apachetutor.org/admin/reverseproxies