neversaint
neversaint

Reputation: 64004

How to set multiple site_dir in shiny-server.conf

Currently my shiny-server.conf looks like this:

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

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

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

Is there a way I can set multiple directories in this line?

site_dir /srv/shiny-server

e.g. by adding /my_favorite/app_path1/ on top of it.

Upvotes: 1

Views: 1397

Answers (1)

Enzo
Enzo

Reputation: 2611

AS I understand it, the question is: "how to set multiple directories in shiny-server"?

This is my shiny-server.conf:

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

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

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

Taking the above into account, you can create as many directories you want under /srv/shiny-server, e.g.:

+---/srv/shiny-server
|   +---Test
|       +---server.R
|       +---ui.R
|   +---Foo
|       +---server.R
|       +---ui.R

Then you connect to each application with: http://<ip address>:3838/Test or http://<ip address>:3838/Foo etc.

Of course, if there is no desire to have physical directories under /srv/shiny-server it is possible to symlink them: for example, the directory sample-apps where the standard examples of shiny are stored, is symlinked from /opt/shiny-server/samples/sample-apps.

It is also possible to have per-users directories, but this seems to be out of the question's scope.

Upvotes: 1

Related Questions