3

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

Kasper Christensen
  • 895
  • 3
  • 10
  • 30

2 Answers2

1

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;
}
pari
  • 788
  • 8
  • 12
0

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;
    }
}
Kasper Christensen
  • 895
  • 3
  • 10
  • 30
  • I'm a bit confused on why port 8080 is being used here, shiny-server is accessed via 3838, why is that not used here? I'm trying to skip the user auth and just have nginx direct port 80 to shiny at 3838 – Garglesoap Aug 05 '18 at 18:02