闪亮的服务器和nginx子域

时间:2017-08-03 22:25:30

标签: nginx shiny shiny-server

我配置了闪亮的服务器,我无法将 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

1 个答案:

答案 0 :(得分:1)

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

我的shiny-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.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;
    }
}