首页 > 解决方案 > 登录 ShinyProxy 后 Apache 重定向到 http

问题描述

我已经成功设置了一个 Apache HTTPD Web 服务器和 ShinyProxy 实例,这样我就可以通过 https 访问一组闪亮的应用程序(在运行 amazon linux 的服务器上)。

当我访问

https://www.example.com

我(如预期的那样)获得了网络应用程序(闪亮的代理)提供的登录页面。现在,它被设置为使用简单的身份验证。

但是,当我登录(成功)时,我正在查看的页面会将我重定向到http://example.com。我需要它保持在 https 上,特别是因为 google auth 不允许您重定向到 http 页面。

我认为问题可能出在我的 apache 配置文件上。相关部分是

<VirtualHost *:80>
  ServerName example.com
  Redirect / https://www.example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName example.com
    DocumentRoot /var/www/

    SSLEngine on
    SSLProxyEngine On
    SSLCertificateFile <path to crt>
    SSLCertificateKeyFile <path to key>
    SSLCertificateChainFile <path to bundle>
    
    # This block is needed for the interal workings off the app
      <Proxy *>
        Allow from localhost
      </Proxy>
     RewriteEngine on
     RewriteCond %{HTTP:Upgrade} =websocket
     RewriteRule /(.*) ws://localhost:3600/$1 [P,L]
     RewriteCond %{HTTP:Upgrade} !=websocket
     RewriteRule /(.*) http://localhost:3600/$1 [P,L]
     ProxyPass / http://localhost:3600/
     ProxyPassReverse / http://localhost:3600/
     ProxyRequests Off
     ProxyPreserveHost On
</VirtualHost>

有人对我如何解决这个问题有任何想法吗?

标签: apacheauthentication

解决方案


我找到了一个解决方案,所以我提供了答案,以防其他人仍然被卡住。

  1. 如果您仍然对我有这个问题,那么问题是我在闪亮的代理 application.yml 文件中包含的主页图像是通过 http 提供的,因此 apache 迫使整个网站返回 http。将默认图像交换为通过 https 提供的图像修复了问题。

  2. 此外,在最新版本的闪亮代理(2.4+)中,您需要在服务器下的应用程序 yml 中包含阻止该行。 forward-headers-strategy: native


推荐阅读