我有一个三层的多层应用程序,可以说公共,业务和工作区(都运行apache)。 客户端请求命中公共服务器,请求被处理并分发到业务服务器上,这些服务器会执行“事情”。并将响应返回给公共服务器,然后公共服务器处理响应并将其传递给客户端。 我有一个场景,其中我想要一个请求说/ rstudio来到公共服务器调度到业务实际上反向代理到工作区服务器。这里有两个问题:
从业务服务器,我已从我的应用程序服务器设置反向代理到Rstudio服务器。
<Proxy *>
Allow from localhost
</Proxy>
ProxyPass /rstudio/ http://business_server/
ProxyPassReverse /rstudio/ http://business_server/
RedirectMatch permanent ^/rstudio$ /rstudio/
这很好(参考https://support.rstudio.com/hc/en-us/articles/200552326-Running-with-a-Proxy)。为了处理动态工作区服务器,我可以使用以下内容,但ProxyPassReverse不支持值的表达式,这种方法没有任何乐趣。
ProxyPassMatch ^/rstudio/(.*)$ http://$1
ProxyPassReverse ^/rstudio/(.*)$ http://$1
RedirectMatch permanent ^/rstudio$ /rstudio/
我已尝试使用mod_rewrite规则(以下),但没有ProxyPassReverse,并且由于GWT Rstudio上的域重定向,这不起作用。添加ProxyPassReverse可以解决问题,但我没有在值部分找到动态工作区服务器问题的表达式。
RewriteRule "^/rstudio/(.*)" "http://$1" [P]
以下是使用LocationMatch和mod_headers解决此问题的第三种方法:
<LocationMatch ^/rstudio/(.+)>
ProxyPassMatch http://$1
Header edit Location ^http:// "http://%{SERVER_NAME}e/rstudio/"
</LocationMatch>
但这也不是一件好事,因为header指令的值不是根据环境变量计算的(并且只有后向引用在这里工作)。如果我有代码business_server,那么我可以让反向代理服务器工作,这是:
<LocationMatch ^/rstudio/(.+)>
ProxyPassMatch http://$1
Header edit Location ^http:// "http://private_server/rstudio/"
</LocationMatch>
问题1: 我想知道是否有更好的方法可以解决此问题而无需在apache conf中对服务器DNS进行硬编码?
问题2: 使用硬编码服务器DNS,反向代理适用于我(不完整但有效)但我遇到了root用户的资源引用的GWT问题请求调度没有完全正常工作。我到达登录页面但找不到资源。
我想知道是否有更好的办法来解决这个问题?
以下是来自浏览器的示例日志:
Navigated to https://public_server/rstudio
rworkspaces:43 GET https://public_server/rstudio.css
rworkspaces:108 GET https://public_server/js/encrypt.min.js
rworkspaces:167 GET https://public_server/images/rstudio.png 404 (Not Found)
rworkspaces:218 GET https://public_server/images/buttonLeft.png 404 (Not Found)
rworkspaces:218 GET https://public_server/images/buttonTile.png 404 (Not Found)
rworkspaces:218 GET https://public_server/images/buttonRight.png 404 (Not Found)