Search code examples
rshinyshiny-server

Shiny Server configuration for personal apps


I am relatively new to shiny-server configuration. Currently there are a bunch of apps being hosted on shiny-server at the root level which can be accessed via http://<ip.address>:3838/appName. I want to allow a service account to be able to deploy apps and be able to check the log files. The service account does not and will not have sudo access. The service account has already been added to a group called shinyUsers. While doing so I still want to make sure the apps currently deployed at root level are still operational and do not get impacted by the change in configuration.

Reading through the configuration guide I get some of the bits around deploying personal applications. However I am unsure about what to add for the site_dir and log_dir keys.

Below is my configuration file so far:

run_as :HOME_USER: shiny;

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

  location / {
    user_dirs;

    # Only allow members of the 'shinyUsers' group to host personal applications.
    members_of shinyUsers;

    # 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 off;

  }

  # Define a location at the base URL
  location / {

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

Solution

  • The below configuration will still keep the root apps running (albiet with a small change in the url) and also provide access to the service account to be able to host apps. The apps need to be in a directory called ShinyApps and the log files will automatically enter a log subdirectory within ShinyApps

    the root level apps will be on the url: http://myserver/appName and the service account apps will be on the url: http://myserver/serviceAccountName/appName . This is because I have included the server name myserver in the below config (use the actual server name here).

    run_as :HOME_USER: shiny;
    http_keepalive_timeout 50000;
    
    # Define a server that listens on port 80
    server {
      listen 80;
    
     
      #replace ip address with name of the server
      server_name: myserver;
    
      location / {
        user_dirs;
    
        # Only allow members of the 'shinyUsers' group to host personal applications.
        # I use a centos7 server so sudo usermod -a -G shinyUsers username
        members_of shinyUsers;
      }
    
      # Define a location at the base URL
      location / {
    
        # 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 off;
      }
    }