我们正在尝试使用 ECS 和 API Gateway 将我们的 aspnetcore Web 应用程序从我们自己的 Windows/IIS 服务器迁移到 AWS。我们一切正常,但在我们的 Web 应用程序中遇到了一个意想不到的重定向问题。我们的网站在 IIS 中是这样设置的:
/ => the root website is pointing to another web app
/app1 => app1 is setup as a virtual directory pointing to an empty folder
/app1/v1 => v1 is setup as an application pointing to an aspnetcore app
/app2/v1 => again v1 is setup as an application pointing to a different aspnetcore app
我有一个非常简单的开箱即用的 aspnetcore 应用程序,它被设置为 /app1/v1 下的虚拟目录。aspnetcore 应用程序中的路由是:
/Web
/Web/Login
/Web/Home
当用户首次访问该站点 ( http://localhost/app1/v1/Web ) 时,他们将使用以下命令重定向到登录页面:
Redirect("~/Web/Login")
当应用程序由 IIS 运行时,导致浏览器被重定向到:
http://localhost/app1/v1/Web/Login
但是,当我使用反向代理(如 AWS API Gateway)时,该代理已使用重定向到的相同虚拟路径进行设置:
http://localhost/Web/Login
我猜在启动期间必须有一个配置值需要传递给 Kestrel,或者作为请求标头告诉它添加“/app1/v1/”到它执行的任何 ~/ 重定向?有谁知道 IIS 如何告诉 Kestrel 完整路径以及我如何复制该行为?