Install R Shiny Server in Ubuntu behind Nginx Proxy

For installing and serving R Shiny Server behind Nginx reverse proxy we first install it by:

sudo apt-get install r-base
sudo su - \
-c "R -e \"install.packages('shiny', repos='')\""
sudo apt-get install gdebi-core
sudo gdebi shiny-server-

Before installing some R Shiney packages we should install:

sudo apt-get install libssl-dev libcurl4-openssl-dev

Then we can install R packages like below:

sudo su - -c "R -e \"install.packages('openssl')\""
sudo su - -c "R -e \"install.packages('tidyverse', dependencies = TRUE , repos='')\""
sudo su - -c "R -e \"install.packages('plotly', dependencies = TRUE )\""
sudo su - -c "R -e \"install.packages('lubridate', dependencies = TRUE )\""
sudo su - -c "R -e \"install.packages('shinyalert')\""
sudo su - -c "R -e \"install.packages('DT')\""

For changing settings :
vim /etc/shiny-server/shiny-server.conf


And for restarting shiney server:


sudo systemctl restart shiny-server


It is time to add the reverse proxy in Nginx as below:

sudo vim /etc/nginx/nginx.conf

server {
     location / shiny {
	proxy_pass http: //localhost:3838/;
	rewrite ^ /shiny/(.*) $ / $1
	proxy_redirect / $scheme: //$http_host/shiny/;
	proxy_http_version 1.1;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection 'upgrade';
	proxy_read_timeout 20 d;
	proxy_buffering off;

Then you need to restart nginx :

sudo service nginx restart

Leave a Reply

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