小编coz*_*alp的帖子

使用 SSL 和 Cookie 身份验证重定向在 Apache 中托管 ASP.NET Core

我制作了一个 asp.net core 应用程序,并尝试使用反向代理将其托管在 Apache 中。该应用程序使用 cookie 身份验证:

app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
  AuthenticationScheme = "CookieAuthentication",
  LoginPath = new PathString("/Account/Login/"),
  AccessDeniedPath = new PathString("/Account/Forbidden/"),
  AutomaticAuthenticate = true,
  AutomaticChallenge = true
});
Run Code Online (Sandbox Code Playgroud)

在 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>
Run Code Online (Sandbox Code Playgroud)

当我使用网址时 https://testserver1:34567时,它会重定向到http://testserver1:34567/Account/Login/?ReturnUrl=%2F,这当然会给出Bad Request。如果我通过将其更改为 https 来更正 url,那么之后一切都会正常工作。

我怎样才能使它始终重定向到 https url?

apache ssl redirect reverse-proxy asp.net-core

4
推荐指数
1
解决办法
1814
查看次数

标签 统计

apache ×1

asp.net-core ×1

redirect ×1

reverse-proxy ×1

ssl ×1