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

时间:2019-06-28 20:50:18

标签: r nginx https shiny shiny-server

我的URL上的Shiny Server正常运行,但是无法从安全连接访问应用程序。

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

现在在浏览器中输入我的URL即可将我直接带到https站点,并带有默认的“欢迎使用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)。

1 个答案:

答案 0 :(得分:0)

好的,原来是c=x行引起了问题。评论说,一切都很好。

相关问题