Premium Feature — This feature supports RStudio, which is part of the Professional and Enterprise Editions of LabKey Server. Learn more or contact LabKey for details.
This topic covers setting up and configuring RStudio Pro. Once you have completed these steps, configure LabKey as described in Connect to RStudio Pro.


AWS Notes

  1. If you're setting this server up in AWS, you will want to set it up in a public subnet in the same VPC as the destination server. It will need a public-facing IP/EIP.
  2. For AWS, the following ports need to be open, inbound and outbound, for this install to work in AWS. Set your security group/NACLs accordingly:
    • 80
    • 443
    • 1080 (license server)
    • 8787 (initial connection)
    • 1024-65535 (license server)

Non-Linux Host OS

  1. VM: (Optional, for non linux host OS) Use Virtual Box to set up a local Linux environment.
  2. Linux: (Optional, for non linux host OS)
  • Install Linux OS:
    • Ubuntu: Download and install latest Ubuntu; version 12.04 or higher is required) in the VM.
  • Configure VM network so that VM has an IP and can be accessed by the host
    • Ex: VM > Settings > Network > Attached To > Bridged Adapter

Set Up R (for Ubuntu)

Use the following steps to set up R for Ubuntu. For other versions of linux, follow the instructions here instead:

1. Configure CRAN Repository. Add the following entry to your /etc/apt/sources.list file, substituting the correct name for your Ubuntu version where this example uses 'xenial' (the name for 16.x):

If you are not sure what name your Ubuntu version is using, you can find it in other lines of the sources.list file.

Linux Tip: to open a system file in linux for editing, use:
$ gksudo gedit  /etc/apt/sources.list
To add edit permission to a file:
$ chmod 777 /etc/apt/sources.list

2. Install latest version of R

apt-get update
apt-key adv --keyserver hkp:// --recv-keys E084DAB9
sudo apt-get install r-base

3. Install Rlabkey and other R packages

  • If a library is to be used by RStudio as a system library (instead of a user library), run with 'lib' set as shown here:
    $ sudo R
    > install.packages("Rlabkey", lib="/usr/local/lib/R/site-library")
    > q()
  • If a library has dependencies:
    > install.packages("package", lib="/usr/local/lib/R/site-library", dependencies=TRUE)
    > q()
Trouble installing Rlabkey on Linux? Try installing dependencies explicitly:
> sudo apt-get install libssl-dev
> sudo apt-get install libcurl4-openssl-dev

Install RStudio Pro

1. Download and install RStudio Pro as instructed when you purchased it. For demo purposes, you can use the free 45 day trial license and download from the RStudio download page.

$ sudo apt-get install gdebi-core
(nb: this URL may not be current. Check the RStudio download page for latest version)

gdebi rstudio-server-pro-1.1.447-amd64.deb (substitute current version)

2. Activation: (Optional)

$ sudo rstudio-server license-manager activate ACTIVATION_KEY

This function requires high ports to be world-accessible. If this command fails, check your security groups or NACLs; if this fails with a timeout, check them first.

3. Verify RStudio Pro Installation

  1. Create a ubuntu user:
    useradd -m -s /bin/bash username
    passwd username
  2. Get Ubuntu’s ip address by:
    $ ifconfig
  3. In VM browser, go to localhost:8787, or ip:8787
  4. You should be on the RStudio Pro login page, login using your ubuntu login
4. Verify accessing RStudio pro from the host machine

In the host machine’s browser, go to http://ubuntuVmIPAddress:8787, you should see the RStudio login page and being able to log in.

Troubleshoot: did you configure VM to use Bridged Adapter?

5. Create a Route 53 DNS name for the server. You will need this for the next steps.

Configure RStudio Pro Proxy

1. You will need to create an SSL cert:

  1. openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 3650 -out certificate.pem
  2. Copy the key.pem file to /etc/ssl/private/
  3. Copy the certificate.pem file to /etc/ssl/certs
  4. Edit /etc/rstudio/rstudio-server.conf and add the following lines:
  5. rstudio-server stop
  6. rstudio-server start
2. Use LabKey server as proxy authenticator for RStudio Pro by adding the following lines to /etc/rstudio/rserver.conf, supplying your own server name:

3. rstudio-server restart

4. Follow the instructions here for downloading the cert:

5. Upload the saved cert to the destination server

6. On the destination Labkey server (nb: this will require restarting the LabKey instance):

  1. Log in.
  2. sudo su -
  3. keytool -import -keystore /usr/lib/jvm/jdk1.8.0_151/jre/lib/security/cacerts -alias <RStudio hostname, but not the FQDN> -file <whatever you named the saved cert>.crt (nb: you will be prompted for a password; ask Ops for it)
  4. service tomcat_lk restart
7. Verify Proxy redirect Go to the RStudio Pro url to verify the page redirects to LabKey. Note: Once SSL is enabled, 8787 no longer works.

8. (Optional) Custom security token

$sudo sh -c "echo 'X-LabKey-RStudio-Header' > /etc/rstudio/secure-proxy-user-header"
$sudo chmod 0600 /etc/rstudio/secure-proxy-user-header

(Optional) Add RStudio Pro Users

LabKey users are mapped to RStudio users by removing the configured "email suffix". For example: LabKey user is mapped to RStudio user name XYZ

Adding RStudio Pro Users

RStudio Pro uses Linux’s PAM authentication so any users accounts configured for Linux will be able to access RStudio Pro. Users can be added for RStudio by the adduser Linux command.

The following commands add a user “rstudio1” to Linux (and hence RStudio pro).

$ sudo useradd -m -d /home/rstudio1 rstudio1
$ sudo passwd rstudio1

IMPORTANT: Each user must have a home directory associated with them otherwise they won’t be able to access RStudio since RStudio works on this home directory.

Verify Access

Verify access to RStudio Pro for the newly added user:

Go to ip:8787, enter user and pw for the newly created user, verify the user can be logged in to RStudio successfully.

Troubleshoot for permission denied error on login:

  1. Run pamtester to rule out PAM issue
    $ sudo pamtester --verbose rstudio <username> authenticate acct_mgmt
  2. Try adding the following line to /etc/sssd/sssd.conf (you may need to install sssd):
    ad_gpo_map_service = +rstudio
  3. Did you create the user with a specified home directory?
  4. Make sure you didn’t configure the RStudio Pro server to limit user access by user group (the default is to allow all; check /etc/rstudio/rserver.conf), or if so make sure your user is added to an allowed group.

General Troubleshooting

After making any change to the RStudio Pro config, always run the following for the change to take effect:

$sudo rstudio-server restart

Related Topics


Was this content helpful?

Log in or register an account to provide feedback

expand all collapse all