R- Shiny Webserver on a Local Server

Shiny server running on localhost can't be accessed from web when redirected by apache

Roughly following this guide https://support.rstudio.com/hc/en-us/articles/213733868-Running-Shiny-Server-with-a-Proxy (but with apache2)

I have had success in using apache2 as a reverse proxy for shiny server when following that guide in detail, in particular the last examples. In your case, you should replace

ProxyPass "/myapp" "http://localhost:2224"
ProxyPassReverse "/myapp" "http://localhost:2224"

with

 RedirectMatch permanent ^/myapp$ /myapp/

RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /myapp/(.*) ws://localhost:2224/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /myapp/(.*) http://localhost:2224/$1 [P,L]
ProxyPass /myapp/ http://localhost:2224/
ProxyPassReverse /myapp/ http://localhost:2224/

Header edit Location ^/ /myapp/
ProxyRequests Off

Run R Shiny App on Apache Server

So you don't run a Shiny app on Apache, Shiny Apps must be run on a Shiny Server. You have several options for deploying a Shiny app to your website. The simplest approach is to publish your app to shinyapps.io then add an IFrame to your website that will display your deployed Shiny app.

Since you have asked about how to run a Shiny App on Apache, I assume you want to deploy your own Shiny Server, which can be deployed on the same machine as your Apache server or on a different machine. Instructions for doing this may be found here: https://www.rstudio.com/products/shiny/download-server/

Once you shiny server is installed you will need to publish your app there. This is accomplished by moving your r files to the appropriate location on your Shiny Server. For details see: http://docs.rstudio.com/shiny-server/#host-a-directory-of-applications-1

Once you have done this and have your app running on Shiny Server, you need to set up Apache(Nginx or another webserver) to act as a proxy to Shiny Server. Here is a link that walks you through the steps: https://support.rstudio.com/hc/en-us/articles/213733868-Running-Shiny-Server-with-a-Proxy

If you have not done this before and do not have experience with Linux or servers, I would expect it to take at least 4 hours.



Related Topics



Leave a reply



Submit