I am using Azure Webapps for Containers to host an R Shiny-Server. I want to use Azure Active Directory to authenticate and authorize the user logging into the app.
I am using the rocker/shiny
image from dockerhub and the image builds and run easily. However, when I am turning on Active Directory the app does not work anymore. Any hints and clues on what might be wrong would be of great help.
I got the same problem of an "empty" page, because loading of static files by the browser returned HTTP 400 when activating AD authentication. I have a Shiny app in a docker container on Azure App Services on the latest version of Shiny server (v1.5.12.933) and Shiny (1.4.0).
This means the problem described here https://community.rstudio.com/t/shiny-v1-3-known-regressions-and-serious-issues/28180/4 which I suspected first is not the reason.
w/o AD authentication the page is displayed correctly. The Azure proxy responsible for AD authentication injects some HTTP headers and cookies. I inspected the full HTTP request on server side via tcpflow -p -c -i eth0 port 3838
and had a look at the underlying R library httpuv
which is responsible for the HTTP connection to the Shiny server.
When searching where in this library HTTP 400 codes are returned I found https://github.com/rstudio/httpuv/blob/master/src/webapplication.cpp and the following code snippet
// Make sure that there's no message body.
if (pRequest->hasHeader("Content-Length") || pRequest->hasHeader("Transfer-Encoding")) {
return error_response(pRequest, 400);
}
while the request arriving at the server had the header Content-Length: 0
which is not present if AD authentication is turned off.
I created a fix and PR for httpuv
, see issue https://github.com/rstudio/httpuv/issues/247.
You can use it as long as it is not merged into their repo.
Just run
R -e 'library(devtools); install_github("LHaferkamp/httpuv")'
in your Dockerfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With