Hosting and setting up own shiny apps without shiny server

RWeb HostingShinyShiny Server

R Problem Overview


I'm trying to make shiny apps available to my coworkers without them having to run or even have R installed.

So I read this webpage and found this sentence:

> If you are familiar with web hosting or have access to an IT > department, you can host your Shiny apps yourself.

under the 'Share as a web page'-section.

How can I do this?

The problem is that my company is bound to certain restrictions regarding web hosting and security and so on, and will not (for now) pay for a shiny-server-pro.

But the sentence above gives me hope to set up something ourselves to convince them.

R Solutions


Solution 1 - R

If your PC and your coworkers PCs belong to the same LAN, this is pretty easy to achieve. Just run your app through:

runApp(host = "0.0.0.0", port = 5050)

The value set through the host argument says to accept any connection (not just from localhost). The port argument can assume any value that you want (just assure to avoid to select ports used by other services like ssh or http). Then, take note of your local IP (if you are under linux, you can see it through ifconfig). Say your IP is 192.168.1.70. Your colleagues can use your app by inserting in the address bar of their browser 192.168.1.70:5050, i.e. your IP followed by : and the port number you selected.

If you want access from outside your LAN, you can direct your router to your PC when someone connect to your public IP through the 5050 port.

Solution 2 - R

Sharing apps over the LAN like this is pretty cool, but it is kind of a hack. I tried it with some co-workers, and it works, but it is more of an office trick than a sustainable solution.

I just finished developing the RInno package for this exact problem, i.e. when a company will not pay for Shiny Server or there are security concerns with cloud services.

To get started:

install.packages("RInno")
require(RInno)
RInno::install_inno()

Then you just need to call two functions to create an installation framework:

create_app(app_name = "myapp", app_dir = "path/to/myapp")
compile_iss()

If you would like to include R for your co-workers who don't have it installed, add include_R = TRUE to create_app:

create_app(app_name = "myapp", app_dir = "path/to/myapp", include_R = TRUE)

It defaults to include shiny, magrittr and jsonlite, so if you are using other packages like ggplot2 or plotly, just add them to the pkgs argument. You can also include GitHub packages to the remotes argument:

create_app(
    app_name = "myapp", 
    app_dir  = "path/to/myapp"
    pkgs     = c("shiny", "jsonlite", "magrittr", "plotly", "ggplot2"),
    remotes  = c("talgalili/installr", "daattali/shinyjs"))

If you are interested in other features, check out FI Labs - RInno

Solution 3 - R

You might want to have a look at the open source solution shinyproxy.

Using shinyproxy you will have to wrap your apps in a docker container to host them.

Here you can find a guide on how to deploy a shiny app in a docker container (which btw. is a good practice, even without using shinyproxy, to maintain the app dependencies).

There are different authentication and scaling methods available.

Solution 4 - R

I have recently installed Shiny on a Centos 7 Linux OS server we have locally. We used the guide below for the most part. https://www.vultr.com/docs/how-to-install-shiny-server-on-centos-7

Feel free to ask any questions about setup problems here so anyone else using the guide can see the answers!

We also looked into pushing it up on a AWS server, opted for our own as the content is sensitive. Otherwise both solutions looked similar. The Linux and Shiny system are light, you might be able to run it on the free Amazon server!

Solution 5 - R

Here's another really "hacky" solution. I recently had to deal with the same issue you faced, and wasn't sure how to get some sort of POC in front of the eyes of those who make the decisions. I knew that they could access a particular shared network drive. So I saved the R binaries to that network drive. The app that I wrote was saved on that same network drive. I then wrote a .R file and saved it in the app's working directory that had these lines in it to set the working directory and source the global variables.

contents of app_start.R

setwd("shared/drive/app_directory")
source("./global.R")
runApp("launch.browser=TRUE")

All of this was started by a batch file (if windows, otherwise a .sh file) with one line that had two parts, the absolute filepath to the R binaries on the network drive, and then the .R script above to run the application

# something to the effect of 
filepath/to/R/bin/Rscript.exe filePath/to/app_start.R

It did the trick for a POC, but definitely would not be a production-worthy solution.

Solution 6 - R

The Web Hosting Data Apps has some tutorials to host Shiny apps using just systemd or docker and make them globally accesible, you can check them out.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionschlusieView Question on Stackoverflow
Solution 1 - RnicolaView Answer on Stackoverflow
Solution 2 - RJonathan HillView Answer on Stackoverflow
Solution 3 - RismirsehregalView Answer on Stackoverflow
Solution 4 - RBenView Answer on Stackoverflow
Solution 5 - Raromatic6tetView Answer on Stackoverflow
Solution 6 - RPabortView Answer on Stackoverflow