闪亮的服务器和 nginx 子域

Shiny server and nginx subdomain

我已经配置了闪亮的服务器,但我无法将 localhost:3838 重定向到 shiny.mywebsite.com

我遵循了这个 Redirect subdomain to port [nginx/flask] 和 RStudio 指南,但没有成功。

我试过了

server {
    listen 80;
    server_name shiny.mywebsite.com;

    location / {
      proxy_pass http://localhost:3838;
    }
}

server {
    listen 80;
    server_name shiny.mywebsite.com;

    root /shiny;

    access_log /var/log/nginx/shiny.access.log;
    error_log /var/log/nginx/shiny.error.log;

    location / {
        index index.html;
        autoindex on;
    }
}

放在/etc/nginx/sites-enabled/shiny.conf中就可以访问localhost:3838但不能访问shiny.mywebsite.com

你应该在 nginx 配置文件中声明端口 80 而不是 shiny-server.conf 我一开始也很困惑。

我的闪亮-server.conf

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

server {

    listen 3838;
  location / {

    site_dir /home/shiny/ShinyApps;

    log_dir /home/shiny/logs;
    directory_index on;
  }
}

我的服务器在 sites-enabled/default

请注意,您的网站将位于 /var/www/shiny.mywebsite.com 目录下。然后您的 shiny 应用程序将可以通过 shiny.mywebsite.com/shiny/YourApps 访问,因为我们在下面设置了代理通行证。

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

    root /var/www/shiny.mywebsite.com;
    # Add index.php to the list if you are using PHP
    index index.html;

    server_name asemenov.com;

    location /shiny/ {
      proxy_pass http://127.0.0.1:3838/;
    }

    location / {
        try_files $uri $uri/ =404;
    }
}