Skip to content

Instantly share code, notes, and snippets.

@raymondben
Created June 3, 2021 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raymondben/879a19817d33ede264c19ab7b9e98f5e to your computer and use it in GitHub Desktop.
Save raymondben/879a19817d33ede264c19ab7b9e98f5e to your computer and use it in GitHub Desktop.
To add shiny server to NecTAR VM that is already running rstudio server:
1. give the machine a DNS entry with https, see https://swift.rc.nectar.org.au/v1/AUTH_a404f16e313b4b09ac35d183a2f95afe/tutorials-jekyll-test-build-I722423cbb7cadc02889ae2f885ea3802f1565276-3/dns-with-designate/01-overview.html
2. install shiny-server https://www.rstudio.com/products/shiny/download-server/ubuntu/
3. check that shiny-server is running on the default port 3838
wget -O - http://localhost:3838
4. update the nginx config following https://support.rstudio.com/hc/en-us/articles/213733868-Running-Shiny-Server-with-a-Proxy
## should have this block outside of the server block
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
## redirect /app to /app/
rewrite ^/app$ $scheme://$http_host/app/ permanent;
# shiny-server
location /app/ {
rewrite ^/app/(.*)$ /$1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:3838;
proxy_redirect / $scheme://$http_host/app/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 20d;
proxy_buffering off;
}
## should also have a block for rstudio-server along the lines of
location / {
proxy_pass http://localhost:8787;
proxy_redirect http://localhost:8787/ $scheme://$http_host/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 20d;
}
## other stuff
}
## check the config:
sudo nginx -t
## reload it:
sudo nginx -s reload
## should see the demo page at https://your-server.cloud.edu.au/app
## apps are served out of /srv/shiny-server
cd /srv/shiny-server
sudo ln -s hello .
## then https://your-server.cloud.edu.au/app/hello/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment