Reverse proxy with request sending (to Rstudio server)

I have a 3-layer layered application that allows you to publish, work and work (everything works apache). Client requests go to public servers, requests are processed and sent to business servers that do the "stuff", and the response is returned to the public server, which then processes the response and sends it to the client. I have a scenario where I want a say / rstudio request to go to a public server sent to the business that does a reverse proxy to the workspace server. There are two ways out here:

  • the workspace server depends on the request.
  • the application running on the workspace server (Rstudio) uses GWT resources and links (static js, css, etc and RPC com resources) on the root url. All redirection in the application also happens on the domain.

On the business server, I have a reverse proxy installed for the Rstudio server from my application server.

<Proxy *>
    Allow from localhost
</Proxy>

ProxyPass        /rstudio/ http://business_server/
ProxyPassReverse /rstudio/ http://business_server/
RedirectMatch permanent ^/rstudio$ /rstudio/

      

and this work is fine (link https://support.rstudio.com/hc/en-us/articles/200552326-Running-with-a-Proxy ). To handle a dynamic workspace server I could use the following, but ProxyPassReverse does not support expression in value, and this is not encouraging with this approach.

ProxyPassMatch    ^/rstudio/(.*)$ http://$1
ProxyPassReverse  ^/rstudio/(.*)$ http://$1
RedirectMatch permanent ^/rstudio$ /rstudio/

      

I tried the same with mod_rewrite rule (further), but without ProxyPassReverse and due to domain redirection to GWT Rstudio it doesn't work. Adding ProxyPassReverse would fix the problem, but I'm not happy with the lack of expression in the value part to solve the dynamic workspace issue.

RewriteRule "^/rstudio/(.*)" "http://$1" [P]

      

Below is a third approach to solving this problem using LocationMatch and mod_headers:

   <LocationMatch ^/rstudio/(.+)>
    ProxyPassMatch http://$1
    Header edit Location ^http:// "http://%{SERVER_NAME}e/rstudio/"
   </LocationMatch>

      

But that's not fun either, because the value of the header directive is not evaluated against an environment variable (and only backreferences work here). Although I can get the reverse proxy working if I had the business_server code that:

   <LocationMatch ^/rstudio/(.+)>
     ProxyPassMatch http://$1
     Header edit Location ^http:// "http://private_server/rstudio/"
   </LocationMatch>

      

Question 1: I was wondering if there is a better way to solve this problem without hardcoding the DNS server in the apache conf?

Question 2: With a hard coded DNS server, a reverse proxy works for me (patchy, but works), but I was struck by the problem of GWT resource links to root and the request submission does not fully work.I get to the signed page but no resources were found.

I was wondering if there is a better way to handle this?

Below is an example of a log from a browser:

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)

      

+3


source to share





All Articles