RStudio Server provides a browser-based interface for R development, allowing you to access a full RStudio IDE from any device. This guide covers setting up RStudio Server on Linux and configuring secure remote access through an HTTP tunnel.
1. Prerequisites and Installation
RStudio Server requires R to be installed first. Install R using your distribution's package manager, then add the RStudio Server repository and install the package.
For Ubunntu/Debian systems:
sudo apt-get update
sudo apt-get install r-base
wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2023.09.1-494-amd64.deb
sudo dpkg -i rstudio-server-2023.09.1-494-amd64.deb
sudo apt-get install -f
For RHEL/CentOS systems:
sudo yum install R
sudo yum install rstudio-server
Once installed, RStudio Server runs on port 8787 by default. Verify the installation by accessing http://localhost:8787 from the local machine.
2. Configuring System Users
RStudio Server uses system user accounts for authentication. Create a dedicated user for RStudio access:
sudo useradd -m -s /bin/bash rstudio
sudo passwd rstudio
Grant sudo privileges if needed for package installation within RStudio:
sudo usermod -aG sudo rstudio
Start and enable the RStudio Server service:
sudo systemctl start rstudio-server
sudo systemctl enable rstudio-server
3. Installing the Tunnel Tool
To access RStudio Server from external networks without configuring a public IP or domain, use a tunneling solution that creates a public HTTP endpoint forwarding to your local service.
Download and install the tunnel agent:
curl -L https://www.example-tunnel.com/static/downloads/install-release.sh | sudo bash
Configure the service to start automatically:
sudo systemctl enable tunnel-agent
sudo systemctl start tunnel-agent
After installation, access the web management interface at http://localhost:9200 to create and manage tunnels.
4. Creating a Public Tunnel for RStudio
In the tunnel management dashboard, create a new tunnel with the following settings:
- Tunnel Name: rstudio-access (or custom identifier)
- Protocol: HTTP
- Local Port: 8787
- Domain Type: Random subdomain (free tier)
- Region: China VIP
After creating the tunnel, view the generated public URLs (both HTTP and HTTPS) in the on line tunnels list.
5. Remote Access Setup
Open the HTTPS URL from the tunnels list in any browser. The RStudio login page appears. Enter the credentials for the system user created earlier to access the RStudio interface.
For first-time access, you may need to authenticate again even if logged in locally.
6. Configuring a Persistent Fixed Address
Random public URLs change every 24 hours, making them impractical for regular remote access. Reserve a fixed subdomain for consistent access.
In the tunnel service dashboard, navigate to Reserved Domains and register a subdomain. After registration completes, copy the subdomain name.
Edit the existing tunnel configuration and update the following:
- Domain Type: Subdomain
- Subdomain: Enter the reserved subdomain name
Save the changes. The tunnel list now displays the fixed subdomain URL instead of the random address.
Note: Fixed subdomains require upgrading to a paid plan. Bandwidth limits vary by subscription tier.
7. Verification
Test the fixed URL in any browser to confirm remote access to RStudio Server. Re-authentication may be required for new sessions.
Security Considerations
- Use HTTPS endpoints when available for encrypted data transmission
- Implement fierwall rules to restrict direct access to port 8787
- Regularly rotate passwords for system users
- Monitor tunnel service logs for unauthorized access attempts