【发布时间】:2017-12-04 01:43:19
【问题描述】:
我已经制作了一个 asp.net 核心应用程序,我正在尝试使用反向代理将它托管在 Apache 中。应用使用cookie认证:
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "CookieAuthentication",
LoginPath = new PathString("/Account/Login/"),
AccessDeniedPath = new PathString("/Account/Forbidden/"),
AutomaticAuthenticate = true,
AutomaticChallenge = true
});
在 httpd.conf 中,我想使用一个仅带有自定义端口的 SSL 主机,该端口提供来自 Kestrel 的内容。
Listen 34567
<VirtualHost *:34567>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
SSLEngine on
SSLProtocol all -SSLv3
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:!RC4+RSA:+HIGH:+MEDIUM:!LOW:!RC4
SSLCertificateFile certs/server.crt
SSLCertificateKeyFile certs/server.key
</VirtualHost>
当我使用 url https://testserver1:34567 时,它会重定向到 http://testserver1:34567/Account/Login/?ReturnUrl=%2F,这当然会给出 Bad Request。如果我通过将网址更改为 https 来更正网址,之后一切正常。
我怎样才能让它总是重定向到 https url?
【问题讨论】:
标签: apache ssl redirect asp.net-core reverse-proxy