当 apache 重定向时,无法从 web 访问本地主机上的闪亮服务器 运行

Shiny server running on localhost can't be accessed from web when redirected by apache

亲爱的 Whosebug,您好!

我在设置 shiny 服务器和 apache2 路由时遇到问题。 大致遵循本指南 https://support.rstudio.com/hc/en-us/articles/213733868-Running-Shiny-Server-with-a-Proxy(但使用 apache2)

我在 127.0.0.1:2224 端口上设置了 shiny 到 运行。当我打开隧道并转发端口时,一切正常,我在本地主机上看到了我的应用程序。

我在 apache 中设置密码和重定向为:

<VirtualHost *:80>
    ServerAdmin karin@localhost
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    ProxyPass "/myapp" "http://localhost:2224"
    ProxyPassReverse "/myapp" "http://localhost:2224"

   <Location /myapp>
    AuthType Basic
    AuthName "Enter your login name and password"
    AuthUserFile /etc/apache2/.htpasswd
    Require valid-user
   </Location>

当我打开 public my.ip/myapp 时,系统提示我登录,然后我被重定向到本地端口 2224,耶!

~不过,app好像坏了。我看不到任何资源、图像、css - 只是应用程序中编码的普通界面 ui.R

我在日志中看到很多404,闪亮的服务器正在网络上寻找所有这些资源,地址为my.ip/shared/whatever - 但资源只能通过 localhost:2224/shared/whatever

访问

...

知道我在哪里弄乱了路由吗?缺少哪些权限,或者尝试在不设置 ssh 隧道和端口转发的情况下访问我的应用程序的哪些内容?

非常感谢任何想法!

Roughly following this guide https://support.rstudio.com/hc/en-us/articles/213733868-Running-Shiny-Server-with-a-Proxy (but with apache2)

在详细遵循该指南(尤其是最后的示例)时,我成功地使用 apache2 作为闪亮服务器的反向代理。在你的情况下,你应该替换

ProxyPass "/myapp" "http://localhost:2224"
ProxyPassReverse "/myapp" "http://localhost:2224"

 RedirectMatch permanent ^/myapp$ /myapp/

 RewriteEngine on
 RewriteCond %{HTTP:Upgrade} =websocket
 RewriteRule /myapp/(.*) ws://localhost:2224/ [P,L]
 RewriteCond %{HTTP:Upgrade} !=websocket
 RewriteRule /myapp/(.*) http://localhost:2224/ [P,L]
 ProxyPass /myapp/ http://localhost:2224/
 ProxyPassReverse /myapp/ http://localhost:2224/

 Header edit Location ^/ /myapp/
 ProxyRequests Off