R- Shiny webserver on a local server
Asked Answered
L

3

38

I have a windows machine with IIS and I can see the IIS welcome page on http://myname/. I have recently started using Shiny through its own server and I can see shiny apps on http://127.0.0.1:port

Now my question is how can I allow others to see my shiny apps on http://myname:port ? (since 127.0.0.1 is not accessible from other computers). Is this possible with the free version of shiny?

Liquorice answered 15/9, 2014 at 23:5 Comment(6)
In order to use Shiny Server, you currently need to set it up on a linux box. But, I admit that it seems like there should be a work around that does not include Shiny Server. For instance, if you have just a few people you want to share it with, you may be able to set up port forwarding... When I faced this same dilemma, I opted to set up an account with shinyapps.io.Serg
if they are on the same network as you, they just need to type the IP address of your machine along with the port that the App is listening to in their browser. You can force the app to be listening to a port by running: runApp("your app name",host="192.168.xxx.xx",port=yyyy) where port is any port you want/accessible to you.Standfast
@pops It seems that Shiny completely ignores the IP and the port on WindowsLiquorice
You can share your shiny apps with people on the same network without the need going through the IIS (I originally had the same Idea/ or running a virtual machine with Linux on my windows machine). However I discovered that the people on the same network can access the App by typing in the IP address with the port in their browser. Im not sure how you're running the app but this is the way I do it: rm(list = ls()) library(shiny) setwd("C:/Users/me/Desktop/TESTING R SHINY") runApp("dashbord test",host="192.168.120.51",port=7775). Then others connect to my App via 192.168.120.51:7775Standfast
I guess not all ports are accessible from other people's computers in the same local network. There might be firewall rules that blocks the external access. Anyway, at least you have to start your app at 0.0.0.0 first (instead of 127.0.0.1), then solve the possible firewall issues.Solomonsolon
Using IP address didn't work for me (the App failed to run), but running it runApp(app, host = "0.0.0.0", port = 7512) (as @Yihui suggested) and then accessing it from another machine in the network using [yourmacninename:7512] works.Nievelt
I
32

You should make following:

  1. Find your IP ("ipconfig" from cmd prompt in Windows)
  2. Set Shiny to start from port "XXXX" and your IP (instead of 127.0.0.1)

    For example:

    options(shiny.port = 7775)

    options(shiny.host = "192.0.0.45")

  3. Run your App

    runApp(app)

Make sure the port is opened in your firewall.

To be a bit more precise, this is how your file startApp.R might look like:

library(shiny)
options(shiny.host = '0.0.0.0')
options(shiny.port = 8888)
runApp('shinyapp')

This is an example of how you would set the options if Shiny was running behind nginx with tcp.

Innominate answered 29/2, 2016 at 14:49 Comment(3)
Andrey, did you get it running on Windows? If so, does it automatically use IIS?Tallu
You can also start it in one command: runApp(port=7775, host='192.0.0.45')Voncile
@influent, as I understand it just needs to open socket at your IP and after that it runs as a web service. IIS has its own web service.Innominate
B
3

The comments have already said this, but in the interest of providing an answer:

You can use shiny server (free and pro) to host apps on your own server. I believe this will allow you to set it up on http://myname/, however shiny server should be running in a linux environment as listed by @pops.

https://www.rstudio.com/products/shiny/shiny-server/

Or

you can use shiny.io to host them for you, with premium versions having the ability to set your own domain

https://www.shinyapps.io/

Beffrey answered 18/8, 2015 at 13:31 Comment(0)
R
2

When using Shiny localy the library set a server in which you can access the Shiny application. If you want to make it accesible on a LAN you have to set up a Shiny server.

You will need a Linux server with R and Shiny instaled, in addition to all the libraries your application needs. To configure it you can follow this

Once the server is totally configured you can add your own applications to the server adding the applications to the folder:

/srv/Shiny-server/myApp

And will be available inyourServerAddress:3838/myApp

Ragucci answered 10/2, 2017 at 13:55 Comment(1)
thanks for clarification. Could you please estimate the effort to do so?Eberto

© 2022 - 2024 — McMap. All rights reserved.