rstudio / shiny-server

Host Shiny applications over the web.
https://rstudio.com/shiny/server
Other
714 stars 289 forks source link

issue (bug?) with user_dirs, site_dirs and :HOME_USER: #98

Open smartinsightsfromdata opened 9 years ago

smartinsightsfromdata commented 9 years ago

I've tried to configure a Centos 6.5 Shiny Server to have user_dirs applications as well as site_dirs, as documented in the 1.3 manual, but with the configuration below (from the manual) nothing works:

run_as :HOME_USER: shiny;
server {

  listen 3838;

location /users {
  user_dirs;
}

location /apps {
  site_dir /srv/shiny-server;
  log_dir /var/log/shiny-server;
  directory_index on;
}
}

It seems that I can have only the two "canned" configurations available e.g. launching

/opt/shiny-server/bin/deploy-example user-dirs
fereshtehRS commented 9 years ago

Can you add here the URLs you are using to access your applications? And also what do you see when you say "nothing works".

Based on your configuration, you should be able to access applications using URLs like these:

http://localhoat:3838/apps/ http://localhost:3838/users//

If these do not work, please mention the version of Shiny Server you are running: shiny-server --version

smartinsightsfromdata commented 9 years ago

@fereshtehRS I get page does not exist. I have a user configured as main with a ShinyApps folder and I couldn't access it with http://localhost:3838/main/hello and I couldn't access the index.html http://localhost:3838/index.html Could you kindly specify the new urls I should use? (may also suggest to make this a bit more clear in the doc?). Thanks

fereshtehRS commented 9 years ago

Sorry, I just noticed that my comment above didn't get parsed correctly. Try these URLS: (assuming you have application called "hello")

http://localhost:3838/users/main/hello http://localhost:3838/apps/hello http://localhost:3838/apps

And thanks for your suggestion on documentation; we look into that.

smartinsightsfromdata commented 9 years ago

@fereshtehRS How come when I use the following (on a shiny server pro eval.)

run_as :HOME_USER: :AUTH_USER: shiny;

I cannot access the admin console at hostname:4151 with

safari can't connect to the server (etc.)

while I can if I delete :AUTH_USER:?

fereshtehRS commented 9 years ago

Please provide the full configuration file (/etc/shiny-server/shiny-server.conf).

smartinsightsfromdata commented 9 years ago

This is the file that works:

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

# Specify the authentication method to be used.
# Initially, a flat-file database stored at the path below.
auth_passwd_file /etc/shiny-server/passwd;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location /users {
    user_dirs;
    }
    location /apps {

    # Only up tp 20 connections per Shiny process and at most 3 Shiny processes
    # per application. Proactively spawn a new process when our processes reach
    # 90% capacity.
    utilization_scheduler 20 .9 3;

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }
}

# Provide the admin interface on port 4151
admin 4151 {

  # Restrict the admin interface to the usernames listed here. Currently
  # just one user named "admin"
  required_user admin;
}

This is the file that does not work:

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

# Specify the authentication method to be used.
# Initially, a flat-file database stored at the path below.
auth_passwd_file /etc/shiny-server/passwd;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location /users {
    user_dirs;
    }
    location /apps {

    # Only up tp 20 connections per Shiny process and at most 3 Shiny processes
    # per application. Proactively spawn a new process when our processes reach
    # 90% capacity.
    utilization_scheduler 20 .9 3;

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }
}

# Provide the admin interface on port 4151
admin 4151 {

  # Restrict the admin interface to the usernames listed here. Currently
  # just one user named "admin"
  required_user admin;
}

Please advise.

fereshtehRS commented 9 years ago

:AUTH_USER: directive can only be used when you use PAM authentication (auth_pam directive). If you check shiny-server.log file with that setting, you'll see an error in this regard, and server hasn't started properly. You won't be able to access your applications either at this point.

PAM authentication, and :AUTH_USER: are features of Shiny Server Pro, and not the open source product.

smartinsightsfromdata commented 9 years ago

I'm using a (temporary licensed) version of Shiny Pro, so PAM authentication and :AUTH_USER: should work. I've deployed the sample shiny-server.conf with

sudo /opt/shiny-server/bin/deploy-example auth

And I could access the Hello application with an authentication screen (of course I added a login password before using sspasswd).

The problem is that when I try to set user_dirs (as in my previous posting above), it does not work.

Are :AUTH_USER: and user_dirs incompatible?

fereshtehRS commented 9 years ago

You can only define :AUTH_USER: when you use PAM authentication:

auth_pam;

http://rstudio.github.io/shiny-server/latest/#auth_user