RStudio Server and Apache

rstudio2To install R and RStudio Server on Ubuntu:

sudo apt-key adv --keyserver --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] xenial/'
sudo apt-get update
sudo apt-get install r-base
sudo -i R
sudo gdebi rstudio-server-1.1.453-amd64.deb

Configure Apache 2.4 to proxy RStudio, install required modules.

sudo apt-get install libapache2-mod-proxy-html
sudo apt-get install libxml2-dev

Edit configuration file 000-default.conf to add the followings. Assuming RStudio runs on default port 8787 and preferred path is /rstudio:

<Proxy *>
	Allow from localhost
< /Proxy *>

RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /rstudio/(.*) ws://localhost:8787/$1  [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /rstudio/(.*) http://localhost:8787/$1 [P,L]
ProxyPass /rstudio/ http://localhost:8787/
ProxyPassReverse /rstudio/ http://localhost:8787/
ProxyRequests Off

Finally restart apache.

sudo a2enmod proxy && sudo a2enmod proxy_http && sudo a2enmod proxy_wstunnel && sudo service apache2 restart


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s