Krz*_*tof 4 .net apache reverse-proxy asp.net-core
我有 apache 作为反向代理。apache的背后是.NET core应用程序。两者都使用 HTTPS。问题是,当我通过代理访问此 .NET 应用程序时,.NET 报告该请求是使用 http 在没有 SSL 的情况下发出的。
Apache 代理配置:
SSLProxyEngine on
<Location "/">
ProxyPass "https://domain:8444/"
ProxyPassReverse "https://domain:8444/"
</Location>
Run Code Online (Sandbox Code Playgroud)
Apache 可以通过https://domain/访问。
当我通过https://domain:8444/地址访问应用程序时,然后httpContext.Request.IsHttps==true和httpContext.Request.Scheme=="https",但是当我通过https://domain/访问应用程序时,然后httpContext.Request.IsHttps==false和httpContext.Request.Scheme=="http"。
当我尝试使用 PHP 进行相同的配置时,一切正常。有什么我可以做的吗?
首先,您必须确保您的 apache 正在设置X-Forwarded-For和X-Forwarded-Proto标头。
其次,您需要让 ASP.NET Core 应用程序意识到这一点。来自文档:
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
Run Code Online (Sandbox Code Playgroud)
这已经发生在UseIISIntegration()(参见源代码)中,但您可能已删除它(或者未在您使用的模板中设置它)。
| 归档时间: |
|
| 查看次数: |
2093 次 |
| 最近记录: |