ASP.NET 表单身份验证不适用于反向代理
我有一个 ASP.NET 应用程序。除了本地用户直接访问应用程序之外,我还想通过反向代理(在 DMZ 中的另一台计算机上运行)将其公开给外部用户,
例如,假设内部用户使用 URL http://intranet1/myApplication/default.aspx,外部用户可能使用 URL http://www.mycompany.com/externalApplication/default.aspx
这通过 URL 重写设置起来非常简单,但有一个问题当表单身份验证打开时。如果外部用户访问该 URL 站点,forms auth 会尝试自动将其发送到登录页面,该页面会将其重定向到相对 url /myApplication/LoginPage.aspx。就 Web 应用程序而言,应用程序根目录位于 /myApplication 而不是 /externalApplication。当然,通过防火墙进入的外部用户无法理解此 URL,因此请求会失败并显示 404,
对此是否有合理的解决方案?
I have an ASP.NET application. As well as local users accessing the application directly, I want to expose it to external users through a reverse proxy (which is running on a different machine in the DMZ)
for example, say internal users use the URL http://intranet1/myApplication/default.aspx, external users might use the URL http://www.mycompany.com/externalApplication/default.aspx
this is quite simple to set up with URL rerwiting, but there is a problem when forms authentication is turned on. if an external user hits the URL site, forms auth tries to automatically send them to the login page which redirects them to the relative url /myApplication/LoginPage.aspx. as far as the web app is concerned, the application root is at /myApplication not /externalApplication. Of course the external user coming in through the firewall does not understand this URL so the request fails with a 404
is there a sensible solution for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应重定向到“/myApplication/LoginPage.aspx”,而应重定向到“~/Login.aspx”,因此它将根据用户点击的 URL 进行正确映射。
You should not redirect to "/myApplication/LoginPage.aspx" but to "~/Login.aspx", so it would be correctly mapped depends on which URL is user hits on.