Search code examples
rshinyr-markdownshiny-serverbookdown

Including a Shiny app hosted in a private server in a published bookdown book


I am having problems trying to do what I believed I would be straightforward: replace a Shiny app hosted in https://www.shinyapps.io/ by the same app hosted in an AWS EC2 server.

What I had before (worked fine, but run out of hours) was:

```{r, echo = FALSE, screenshot.opts = list(delay = 15), dev = 'png', 
cache = TRUE, fig.align = 'center', out.width = '90%'}
knitr::include_app('http://user.shinyapps.io/least-squares/', height = 
'900px')
```

What I was trying:

```{r, echo = FALSE, screenshot.opts = list(delay = 15), dev = 'png', 
cache = TRUE, fig.align = 'center', out.width = '90%'}
knitr::include_app('http://ec2-35-177-34-200.eu-west-
2.compute.amazonaws.com:3838/least-squares/', height = '900px')
```

You can see that indeed the app is running as it should in

http://ec2-35-177-34-200.eu-west-2.compute.amazonaws.com:3838/least-squares/ [EDIT: now disabled]

Furthermore, the second piece of code produces html documents that adequately show the application locally (they are produced from a .Rmd file). The problem comes when the book is published to http://bookdown.org; there the apps do not show if I use the second piece of code (with the firs one is fine).

Any idea on what's going on?


Solution

  • You cannot use HTTP resources on a web page served via HTTPS. See this post for more information: Allow loading HTTP resources over HTTPS

    Your app hosted on ShinyApps.io worked because it was served via HTTPS.