Opening RStudio using AWS' SSL certificate v2

Woops. Sorry about that :man_facepalming: I forgot the other ProxyPassReverse. I think this should work. Maybe :see_no_evil:

<VirtualHost *:80>

  <Proxy *>
    Allow from localhost
  </Proxy>


#Proxy to RStudio:
  RedirectMatch permanent ^/rstudio$ /rstudio/

  RewriteEngine On

  # force HTTPS
  RewriteCond %{HTTP:X-Forwarded-Proto} !=https
  RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

  # proxy websockets
  RewriteCond %{HTTP:Upgrade} =websocket
  RewriteRule /rstudio/(.*)     ws://localhost:8787/$1  [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket
  RewriteRule /rstudio/(.*)     http://localhost:8787/$1 [P,L]

  #proxy traffic to RStudio
  ProxyPass /rstudio/ http://localhost:8787/
  ProxyPassReverse /rstudio/ http://localhost:8787/
  ProxyPassReverse /rstudio/ https://localhost:8787/

  ProxyRequests off
</VirtualHost>

Basically, you need (1) the redirect to HTTPS to work (it's not currently) and (2) the ProxyPassReverse to work (the problem with localhost:8787).

(1) is discussed in more detail here. I made some changes that I hope will fix it...

(2) is hopefully handled by:

  ProxyPassReverse /rstudio/ https://localhost:8787/

It's worth noting that another possibility is that your AWS load balancer is never sending the X-Forwarded-Proto header, in which case you may have the wrong protocol specified in your TargetGroup or ELB setup. The protocol should be HTTP (not TCP):

Note that TCP load balancers do not support the X-Forwarded-* headers

1 Like