nginx 和 shiny 服务器的尾部斜杠

nginx 和 shiny 服务器的尾部斜杠

尝试在不使用尾部斜杠的情况下加载 Shiny 应用。这是我启用站点的

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;
    }

}

当我去http://mschwarz.us/shiny/test-apps/hello我被重定向到http://mschwarz.us/test-apps/hello/

以下是 Shiny 日志的最后几行:

^[[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.

谢谢!

答案1

这行

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

因为添加了尾部斜杠,所以您为以 开头的每个请求添加斜杠。/shiny/此行的另一个原因是?末尾没有斜杠

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

相关内容