Listed below are all the directives that are supported in Shiny Server config files.
Applies to indicates the kind of parent scope that this directive normally appears inside.
Inheritable means that you can put this directive at a higher level in the hierarchy and it will be inherited by any children to which it might apply. Inherited directives can be overridden by using the directive again in a child scope.
The user the app should be run as. This user should have the minimal amount of privileges necessary to successfully run the application (i.e. read-only access to the Shiny application directory). Note that this directive cannot be used with user_apps, as user_apps always run as the user who owns the application.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| users | String | multiple | The username that should be used to run the app. If using home_dirs, this can also be the special keyword :HOME_USER: which will instruct home_dirs to run as the user in whose home directory the application exists. The special keyword :PROCESS_USER: resolves to the user running the shiny-server process, useful for development without root privileges or for containerized environments where the server runs as a single non-root user. If using a special keyword like :HOME_USER:, you can specify additional usernames afterwards which will be used when this directive is applied to hosting models other than home_dirs. |
The file path of the HTTP access log.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| path | Path | required | The file path where the access log should be written | |
| format | String | optional | The log file format; see Connect documentation under "Formats" | default |
Top-level
Yes
Declares an HTTP server. You need one of these for each port/IP address combination this Shiny Server instance should listen on.
This directive has no parameters.
Top-level
Yes
listen, server_name
Directs the enclosing server scope to listen on the specified port/IP address combination.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| port | Integer | required | Port to listen on | |
| host | String | optional | IP address to listen on (* or :: for all, or 0.0.0.0 for all IPv4); hostnames are not allowed, please use raw IPv4 or IPv6 address only. IPv6 zone IDs are not supported. |
* |
server
Yes
Directs the enclosing server scope to only honor requests that have the given host headers (i.e. virtual hosts).
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| names | String | multiple | The virtual hostname(s) to bind this server to |
server
Yes
Creates a scope that configures the given URL as a website (site_dir), specific application (app_dir), autouser root (user_apps), autouser root with run_as support (user_dirs), or redirect to a different URL (redirect).
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| path | String | required | The request path that this location should match |
server, location
Yes
run_as, location, site_dir, directory_index, user_apps, user_dirs, app_dir, redirect, log_dir, log_file_mode, members_of, google_analytics_id, application, template_dir, python, bookmark_state_dir, disable_websockets, disable_protocols, log_as_user, reconnect, sanitize_errors, frame_options
Configures the enclosing location scope to be a website that can contain both Shiny applications and unrelated static assets in a single directory tree.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| rootPath | Path | required | The path to the root directory of the website |
location
Yes
When enabled, if a directory is requested by the client and an index.html file is not present, a list of the directory contents is created automatically and returned to the client. If this directive is not present in a custom config file, the default behavior is to disable directory indexes. However, it is enabled if no config file is present at all (in other words, the default config file has it enabled).
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| enabled | Boolean | required | Whether directory contents should automatically displayed |
DEPRECATED! This directive has been deprecated in favor of user_dirs, which offers more flexibility with regards to the run_as configuration. Configures the enclosing location scope to be an autouser root, meaning that applications will be served up from users' ~/ShinyApps directories and all Shiny processes will run as the user in whose directory the application is found.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| enabled | Boolean | optional | Whether this location should serve up all users' ~/ShinyApps directories | true |
location
Yes
Configures the enclosing location scope to be an autouser root, meaning that applications will be served up from users' ~/ShinyApps directories. This directive does respect an affiliated run_as setting, meaning that the applications will be executed as whichever user is configured in the applicable run_as setting. Note that many distributions, by default, will prohibit users from being able to access each other's home directories.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| enabled | Boolean | optional | Whether this location should serve up all users' ~/ShinyApps directories | true |
location
Yes
Configures the enclosing location scope to serve up the specified Shiny application.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| path | Path | required | The path to the Shiny application directory |
location
Yes
Configures the enclosing location to redirect all requests to the specified URL.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| url | String | required | The URL (or base URL) to redirect to | |
| statusCode | Integer | optional | The status code to send with the response (usually 301 for permanent redirects or 302 for temporary redirects) | 302 |
| exact | Boolean | optional | Whether to match on the URL exactly; if false, any subpaths will match as well | true |
location
Yes
Directs the application to write error logs to the specified directory. Only applies to location scopes that are configured with app_dir or site_dir, as user_apps (autouser) always writes error logs to ~/ShinyApps/log. In addition, starting in v1.5.13 you can set the environment variable SHINY_LOG_STDERR to any non-empty value to instruct Shiny Server to emit stderr output from Shiny apps to the main process's own stderr.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| path | Path | required | The path to which application log files should be written |
Specifies the file permissions to use for newly created application log files. Since Shiny Server v1.5.8, umask will be ignored; the mode will be applied via chmod.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| mode | String | optional | The file mode to use, interpreted as an octal number. Set this to 0644 to allow all users on the system to read log files. |
0640 |
Restricts a user_apps or user_dirs (autouser) scope to require membership in one or more groups (or, if no arguments are passed, lifts group restrictions from a members_of directive in a parent scope).
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| groups | String | multiple | Users must be a member of at least one of these groups in order to deploy applications; if no groups are provided, then all users are allowed |
Configure Google Analytics tracking code to be inserted in Shiny application pages.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| gaid | String | required | The Google tag ID, for example, G-123ABCD |
Defines the amount of time Shiny Server will wait for an R process to start before giving up.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| timeout | Integer | required | The number of seconds to wait for the application to start. |
Top-level, server, location, application
Yes
Defines the amount of time an R process will persist with no connections before being terminated. Defaults to 5 seconds. Set to 0 to disable.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| timeout | Integer | required | The number of seconds to keep an empty R process alive before killing it. |
Top-level, server, location, application
Yes
Defines how long a keepalive connection will sit between HTTP requests/responses before it is closed. Defaults to 45 seconds.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| timeout | Float | required | The number of seconds to keep a connection alive between requests/responses. |
Top-level
Yes
Whether gzip/deflate compression is supported for HTTP responses. If this directive is not included, the default behavior is to support gzip/deflate compression.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| enabled | Boolean | optional | Whether or not this is enabled. Default is true. | true |
Top-level
Yes
How often the SockJS server should send heartbeat packets to the server. These are used to prevent proxies and load balancers from closing active SockJS connections. Defaults to 25 seconds.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| delay | Float | required | The number of seconds to wait between heartbeat packets. |
Top-level
Yes
How long the SockJS server should wait between HTTP requests before considering the client to be disconnected. Defaults to 5 seconds. If this value needs to be adjusted above 10 seconds, it's a good idea to disable websockets using the disable_websockets directive, as that transport protocol has an effective 10 second limit built in.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| delay | Float | required | The number of seconds to wait before giving up. |
Top-level
Yes
A basic scheduler which will spawn one single-threaded R worker for each application. If no scheduler is specified, this is the default scheduler.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| maxRequests | Integer | optional | The maximum number of requests to assign to this scheduler before it should start returning rejecting incoming traffic using a '503 - Service Unavailable' message. Once this threshold is hit, users attempting to initialize a new session will receive 503 errors. | 100 |
Top-level, server, location, application
Yes
If present, will allow users to override the global defaults for a scheduler by customizing the parameters associated with a scheduler or even the type of scheduler used.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| enabled | Boolean | optional | Whether or not this is enabled. Default is true. | true |
Top-level
Yes
DEPRECATED. This setting is deprecated and no longer enforced in Shiny Server. It will be ignored.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| empty | String | required |
location
Yes
app_init_timeout, app_idle_timeout, simple_scheduler
A directory containing custom templates to be used when generating pages in Shiny Server.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| dir | Path | required | The directory containing HTML templates. |
Specifies the Python executable (or virtual environment) that should be used to execute Shiny for Python applications.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| path | String | required | One of the following: 1) the absolute path to a Python executable, 2) the absolute path to a virtualenv/venv directory, 3) a bare executable name (e.g. python3.9) which can be found on the PATH, 4) a relative path (to a Python executable or virtualenv/venv directory) to be resolved starting from the directory containing the Shiny for Python application. |
A directory for storing persisted application state. If Shiny Server is running without root privileges, then the run_as account must have read/write access to this directory. If no bookmark_state_dir directive is provided, /var/lib/shiny-server/bookmarks will be used.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| dir | Path | required | The directory where bookmark data should be stored. |
Disable WebSockets on connections to the server. Some networks will not reliably support WebSockets, so this setting can be used to force Shiny Server to fall back to another protocol to communicate with the server. This is equivalent to adding 'websocket' to disable_protocols
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| val | Boolean | optional | Whether or not WebSockets should be disabled. | true |
Disable some of the SockJS protocols used to establish a connection between your users and your server. Some network configurations cause problems with particular protocols; this option allows you to disable those. If your Shiny apps are loading but are unable to show outputs or maintain connections, try disabling 'websocket', then both 'websocket' and 'streaming'. If problems persist, it's unlikely that they are caused by compatibilities with SockJS, as the only remaining protocols are 'polling' which should work well with just about any reasonable HTTP proxy, load balancer, VPN, etc.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| names | String | multiple | The protocol(s) to disable. Available protocols are: 'websocket', 'xdr-streaming', 'xhr-streaming', 'eventsource', 'iframe-eventsource', 'htmlfile', 'iframe-htmlfile', 'xdr-polling', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling'. You can also specify 'streaming' to disable all protocols that use streaming, and 'polling' to disable all protocols that use polling. Note: The eventsource and htmlfile protocols were introduced in v1.5.17. To prevent breaking existing Shiny Server installations with carefully configured protocol lists, the eventsource or htmlfile protocols will be disabled if iframe-eventsource or iframe-htmlfile protocols (respectively) are disabled. |
By default, log files from Shiny processes that exited successfully (exit status 0) will be deleted. This behavior can be overridden by setting this property to true in which case Shiny Server will not delete the log files from any Shiny process that it spawns. WARNING: This feature should only be enabled when combined with proper log rotation. Otherwise, thousands of log files could quickly accrue and cause problems for the file system on which they are stored.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| enabled | Boolean | optional | Whether or not logs should be preserved. | false |
Top-level
Yes
By default, the log files for R processes are created and managed by the user running the server centrally (often root). In the typical scenario in which the logs are stored in a server-wide directory, this is desirable as only root user may have write access to such a directory. In other cases, such as using user_dirs on a system in which the users' home directories are on an NFS mount which uses root_squash, creating log files as root may be a problem. In those scenarios, this option can be set to true to have the log files created by the users running the associated processes.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| enabled | Boolean | optional | Whether or not the log files should be managed by the owner of the process to which they belong. | false |
When a user's connection to the server is interrupted, Shiny Server will offer them a dialog that allows them to reconnect to their existing Shiny session for 15 seconds. This implies that the server will keep the Shiny session active on the server for an extra 15 seconds after a user disconnects in case they reconnect. After the 15 seconds, the user's session will be reaped and they will be notified and offered an opportunity to refresh the page. If this setting is false, the server will immediately reap the session of any user who is disconnected.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| enabled | Boolean | optional | Whether or not to offer to automatically reconnect disconnected users. | true |
If this setting is true (the default), only generic error messages will be shown to the client (unless these were wrapped in safeError()).
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| enabled | Boolean | optional | Whether or not to sanitize error messages on the client. | true |
Sets the X-Frame-Options header on URLs served from Shiny applications, to prevent the app from being embedded in a browser frame or iframe. This can be used as a mitigation for clickjacking attacks. If no option is provided, the default behavior is allow.
| Parameter | Data type | Type | Description | Default |
|---|---|---|---|---|
| value | String | required | One of allow, deny, sameorigin, or allow-from (case insensitive). (allow removes the X-Frame-Options header.) |
|
| url | String | optional | If value is allow-from, the URL from which framing should be allowed. |