Deploy RStudio Server with SSL Support

Deploy RStudio Server with SSL Support

(Source Image: RStudio Server logo https://www.rstudio.com/about/logos/)

RStudio Server is integrated development environment for R language. It includes everything from terminal, syntax-highlighting editor or I should say everything that R has but its running in the web. In this article I’ll show you how to deploy RStudio Server with SSL support on GNU/Linux Lubuntu 16.04.

1. RStudio Server

You must have r-base package before installing RStudio Server. Use this command to install r-base and RStudio Server Open Source License.

sudo apt install r-base
sudo apt-get install gdebi-core
wget https://download2.rstudio.org/rstudio-server-1.0.143-amd64.deb
sudo gdebi rstudio-server-1.0.143-amd64.deb

This should install RStudio Server and default installation running on port 8787. After installation you can browse your browser in this address http://localhost:8787 or in different environment localhost will be your local private IPv4 (http://your-ip-address:8787).

2. Nginx and Let’s Encrypt

RStudio Server Open Source License default installation doesn’t have any SSL support. We can use Nginx web server as proxy and use let’s encrypt for SSL support to make our deployment more secure.

sudo apt install nginx
sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install certbot

3. Nginx Configuration

Nginx configuration on GNU/Linux Lubuntu 16.04 at /etc/nginx. Put our configuration in /etc/nginx/sites-available. Remember to configure your DNS properly so it can answer your subdomain / domain. I’m not cover this article with DNS configuration.

sudo touch /etc/nginx/sites-available/rstudio.clouds.web.id

Fill the rstudio file using configuration

server {
listen 443 ssl;
listen [::]:443 ssl;

root /var/www/html/rstudio.clouds.web.id;

server_name rstudio.clouds.web.id;

location ~ /.well-known {
allow all;
}

location / {
try_files $uri @proxy;
}

location @proxy {
proxy_pass http://127.0.0.1:8787;
proxy_read_timeout 90;
}
}

Don’t forget to link rstudio.clouds.web.id file into sites-enabled in /etc/nginx.

cd /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-available/rstudio.clouds.web.id rstudio.clouds.web.id

Activate let’s encrypt ssl support.

sudo certbot certonly –webroot –webroot-path=/var/www/html/rstudio.clouds.web.id -d rstudio.clouds.web.id

4. RStudio Server Configuration

Stop the RStudio Server

sudo rstudio-server stop

and configure the ip address so it listen only in 127.0.0.1. Configuration file in /etc/rstudio/rserver.conf

www-address=127.0.0.1

Now start RStudio Server again

sudo rstudio-server start

Now test your RStudio Server and voila.

Leave a Reply

Your email address will not be published. Required fields are marked *