3

Trying to get Shiny apps to load without using trailing slashes. Here is my sites-enabled

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.html index.htm index.nginx-debian.html;

    server_name mschwarz.us;

     location /shiny/ {
             proxy_pass http://127.0.0.1:3838/;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
             rewrite ^(/shiny/[^/]+)$ $1/ permanent;
    }

      location /rstudio/ {
             proxy_pass http://127.0.0.1:8787/;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
    }

      location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
    }

}

What happens when I go to http://mschwarz.us/shiny/test-apps/hello is I am redirected to http://mschwarz.us/test-apps/hello/

Here are the last few lines in the shiny log:

^[[33m[2017-02-26 22:50:57.118] [WARN] shiny-server - ^[[39mNo host header sent by user-agent undefined
^[[31m[2017-02-27 07:18:07.658] [ERROR] shiny-server - ^[[39mFailed to render error 500 page: Can't set headers after they are sent.

Thanks!

Michael
  • 31
  • 2
  • Why do you have localhost in your server_name? Remove it unless you have a good reason to have it there, it's redundant. What's sending the redirect, shiny or Nginx? Please edit your question to include applicable logs. – Tim Feb 27 '17 at 03:29
  • Thanks. I will remove localhost and locate the logs this evening – Michael Feb 27 '17 at 17:02

1 Answers1

0

This line

rewrite ^(/shiny/[^/]+)$ $1/ permanent;

cause adding the tailing slash, you add slash for every request starts with /shiny/ Is another reason for this line? without slash at the end is

rewrite ^(/shiny/[^/]+)$ $1 permanent;
Quantim
  • 1,269
  • 11
  • 13
  • For some reason the trailing slash is required i.e 'mschwarz.us/shiny/test-apps/hello' will not work. – Michael Feb 27 '17 at 17:01