Shiny v1.3 known regressions and serious issues

Apps not loading correctly behind NGINX proxy

Background

We've had a number of reports of users upgrading to Shiny v1.3.0 and finding that their apps work fine locally, but not on Shiny Server (and presumably RStudio Server and RStudio Connect) when running behind an NGINX proxy. The HTML loads, but none of the styles are applied and none of the calculations run.

Thank you to all of you who reported this, especially @rogerjbos, who graciously spent part of his day screensharing with our engineers.

The cause

We've identified the cause as a subtle and common misconfiguration of NGINX, specifically a line like this:

proxy_set_header Connection "upgrade";

This directive causes NGINX to add a Connection: upgrade header to every HTTP request, when it's only supposed to be used for WebSockets.

This line is recommended by NGINX Inc. themselves, here and here; however, those recommendations are intended for proxying of traffic that is exclusively WebSockets, whereas Shiny traffic is a combination of normal HTTP requests and WebSockets. Older versions of shiny/httpuv didn't mind this situation, but the new versions are stricter.

Fixing your proxy configuration

To fix the issue in your NGINX configuration, use the following articles as guides:

All of these articles use NGINX directives that are appropriate for both normal HTTP requests and WebSockets. First, a map directive is used to dynamically set a $connection_upgrade variable:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

Then, that variable is used to set the Connection header.

proxy_set_header Connection $connection_upgrade;

Future steps

Because this is such a common configuration for NGINX, and we know that not all Shiny users own the proxies that their apps run behind, the next version of httpuv will relax its interpretation of the Connection header. You can install the GitHub version of httpuv today with remotes::install_github("rstudio/httpuv"), or wait for the CRAN release of httpuv 1.5.2, which we hope to submit in the next couple of weeks.

9 Likes