pachadotdev
pachadotdev

Reputation: 3765

Shiny server and nginx subdomain

I have configured shiny server ok and I cannot redirect localhost:3838 to shiny.mywebsite.com

I followed this Redirect subdomain to port [nginx/flask] and RStudio guides but no success.

I tried

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

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

and

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

to be put in /etc/nginx/sites-enabled/shiny.conf and just can access localhost:3838 but no shiny.mywebsite.com

Upvotes: 0

Views: 1180

Answers (1)

Pork Chop
Pork Chop

Reputation: 29397

You should declare port 80 in nginx configuration file and not the shiny-server.conf I was confused at the start too.

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

My server within sites-enabled/default.

Note that your website will be under /var/www/shiny.mywebsite.com directory. Then your shiny apps will be accessible via shiny.mywebsite.com/shiny/YourAppsas we set up a proxy pass below.

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

Upvotes: 1

Related Questions