Kasper Christensen
Kasper Christensen

Reputation: 915

How can I configure shiny-server to run via NGINX on Ubuntu?

I am trying to configure a NGINX server so that a shiny server and shiny applications can be run via NGINX with proper password protection. My NGINX default file is shown in the example below:

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

    root /srv/shiny-server/;
    #index index.html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        proxy_bind 127.0.0.1;
        proxy_pass http://localhost:8080/;
        proxy_redirect http://localhost:8080/ $scheme://$host/;
        auth_basic "Username and Password are required"; 
        auth_basic_user_file /etc/nginx/.htpasswd;

        try_files $uri $uri/ =404;
    }
}

When I go to localhost:80 the shiny welcome page is displayed but the two apps "hello" and "rmd" does not run (See screenshot below).enter image description here

Doesn anyone have a clue about what I am doing wrong here?

Help would be highly appreciated.

Kasper

Upvotes: 4

Views: 1932

Answers (2)

pari
pari

Reputation: 808

You need to add the location of your app in the cofiguration file of nginx too, such as :

location /hello {
    proxy_bind 127.0.0.1;
    proxy_pass http://localhost:8080/hello;
}

Upvotes: 1

Kasper Christensen
Kasper Christensen

Reputation: 915

Here is how the default file in nginx "sites-available" is supposed to look like. Remember to also configure the R shiny server file.

server {
    listen 80;

    location / {
        proxy_pass http://127.0.0.1:8080/;
            proxy_redirect http://127.0.0.1:8080/ $scheme://$host/;
            auth_basic "Username and Password are required"; 
            auth_basic_user_file /etc/nginx/.htpasswd;
    }
}

Upvotes: 0

Related Questions