繁体   English   中英

带有nginx和https的闪亮服务器:404适用于应用

[英]Shiny server with nginx and https : 404 for apps

我的URL上的Shiny Server工作正常,但是无法通过安全连接访问应用程序。

我使用Certbot安装SSL证书,然后按照本指南中的步骤3设置反向代理。

现在,在浏览器中输入我的URL即可直接将我直接转到https站点,并使用默认的“ Welcome to Shiny Server!”。 页面(即,我的服务器IP位于端口3838)。 所有文字都在那里(“如果您看到此页面,则表示已安装Shiny Server ...等”)。

问题在于示例应用程序未显示-它们都返回“ 404 Not Found”。

我的Nginx服务器文件(nginx / sites-available / shiny-server)如下所示:

server {
    listen 80 ;
    listen [::]:80 ;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;
    server_name myURL.com; # managed by Certbot

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot

    ssl_certificate /etc/letsencrypt/live/myURL.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/myURL.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

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

        proxy_pass http://server.ip.address:3838/;      
        proxy_redirect http://server.ip.address:3838/ https://$host/;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_read_timeout 20d;
    }
}

我曾尝试根据Stack Overflow和其他地方(例如here )的其他答案以多种方式修改location部分,但没有任何方法可以解决问题。

我在nginx.conf的底部添加了以下内容:

# Map proxy settings for RStudio
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

我的shiny-server.conf看起来像这样(默认):

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }
}

如果我访问http://my.server.ip:3838http://myURL.com:3838 ,则这些应用程序运行良好,但是如果我访问https://myURL.comhttp:// myURL ,则该应用程序将无法正常运行。 com (两种情况下均会加载“发光服务器”页面,但示例应用程序为404)。

好的,结果行try_files $uri $uri/ =404; 造成了问题。 评论说,一切都很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM