While running a shinyApp, automatically an URL gets created. Thanks to comments to my prior question I now understand that this URL is not online for public access but restricted to my PC and, if connencted to the same LAN, to my coworkers (see answer here). How can I restrict the shinyApp to the one computer where it runs, i.e. not even users of same LAN can run the app?
To make it reproducible:
library(shiny)
ui <- fluidPage("Some app")
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
For this minimal example, how can we avoid "Listening on http://..." that gets printed to the console and gives others access to my app? I tried to play around with the port
argument of runApp()
function, inserting NA
and NULL
, but can not figure out how to do this.
Background: I work for a big clinic with about 100 buildings and more then 5,000 employees. It depends on different things what data an employee may access (the working unit, profession, ...). My app contains sensible data and I must not allow access to anyone being in our LAN. In fact, my app is build for a certain usecase which is done by only one person. Thus, I want fully restrict the app to one computer.
CodePudding user response:
By default your app is accessible only on the localhost (your PC).
Please see
?runApp()
The default for the host parameter is:
host = getOption("shiny.host", "127.0.0.1"),
The shiny.host
variable by default is unset:
getOption("shiny.host")
# NULL
Accordingly, to make sure your app is accessible only from the localhost use:
runApp(host = "127.0.0.1")
Applied to your example code:
library(shiny)
ui <- fluidPage("Some app")
server <- function(input, output) {}
app <- shinyApp(ui = ui, server = server)
runApp(appDir = app, port = getOption("shiny.port"), host = "127.0.0.1")