Hosting an R Shiny app on your VM
This guide assumes you have spun up an Ubuntu 20.04 LTS VM on CloudCIX with the appropriate compute resources (RAM/storage) for your Shiny app and tools for working on a VM (see Installing Basics)
For simple apps, 1 CPU, 2 GB RAM and 10 GB storage should be sufficient.
The following firewall rules should be added to your VM to allow the appropiate traffic:
Action |
Source |
Destination |
Protocol |
Port |
Explanation of firewall rule |
|---|---|---|---|---|---|
Allow |
|
10.0.0.0/24 |
Any |
- |
Grants your IP access to all VMs in CloudCIX project |
Allow |
* |
|
TCP |
80 |
Required later for certbot access |
Allow |
* |
|
TCP |
443 |
Allows encrypted web traffic access to Shiny app once reverse proxy server is set up |
Install Shiny server by following the instructions for Ubuntu.
Note
Installing R with sudo apt-get (as specified in the Install Shiny Server instructions above) installs R version 3.6.3.
If you require a more recent version, you can install R on Ubuntu from CRAN repository by following method 2 here: https://phoenixnap.com/kb/install-r-ubuntu
Your Shiny app should now be accessible at the following address: VM_public_IP:3838/your_shiny_app_name
Setting up a reverse proxy server to encrypt traffic (recommended)
Note
The following method requires that your VM has a registered domain name. For this, you may request a subdomain for your VM from CloudCIX e.g.:
yourlab.cloudcix.com
Install NGINX on your VM. Follow the “Install prebuilt ubuntu package from official NGINX repo” instructions.
Register for an SSL cert which can be obtained from Let’s Encrypt. These are free, valid for three months and can be configured to auto renew.
Once the above steps are completed, add the following lines in the server block of your NGINX conf file (usually located in the /etc/nginx/conf.d/ directory):
location / { proxy_pass http://127.0.0.1:3838/; }
Test that the NGINX configuration is correct by running:
sudo nginx -t
If the test is successful, reload NGINX to apply changes:
sudo systemctl reload nginx
That’s it, you’re done! Your Shiny app should now be accessible at:
https://yourlab.cloudcix.com/your_shiny_app_name