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='https://cran.rstudio.com/')\""
sudo apt-get install gdebi-core
sudo gdebi shiny-server-1.5.16.958-amd64.deb
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='https://cran.rstudio.com/')\""
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
break;
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