Skip to content

App Configuration Guide

Aaron Coburn edited this page Feb 12, 2019 · 10 revisions

Configuring Trellis Applications

The web application wrapper (Dropwizard.io) makes many configuration options available. Any of the configuration options defined by Dropwizard can be part of your application's configuration file.

The application configuration can typically be found at /opt/trellis/etc/config.yml, though if Trellis is installed manually, it may be in a different location.

Trellis defines its own configuration options, including:

resources: /path/to/resources
Name Default Description
resources (none) Triplestore App only: the path for storing resources. If not defined, an in-memory dataset will be used. If this value begins with http:// or https://, a remote triplestore will be used.
database:
  driverClass: org.postgresql.Driver
  user: changeme
  password: changeme
  url: jdbc:postgresql://db/db-name
Name Default Description
database (none) Database App only: for details on configuring a database connection, please refer to the Dropwizard manual.
binaries: /path/to/binaries
Name Default Description
binaries (none) The path for storing binaries
mementos: /path/to/mementos
Name Default Description
mementos (none) The path for storing mementos
baseUrl: http://localhost:8080/
Name Default Description
baseUrl (none) A defined baseUrl for resources in this partition. If not defined, the Host request header will be used
hubUrl: http://hub.example.com/
Name Default Description
hubUrl (none) A SubHub URL to be added to resource headers, if configured
namespaces: /path/to/namespaces.json
Name Default Description
namespaces (none) The path to a JSON file defining namespace prefixes
auth:
    adminUsers: []
    webac:
        enabled: true
        cacheSize: 1000
        cacheExpireSeconds: 600
    jwt:
        enabled: true
        key: base64-encoded-secret
    basic:
        enabled: true
        usersFile: /path/to/users.auth
    realm: trellis
Name Default Description
adminUsers (none) A list of webIDs that should be given admin access for the purpose of authorization
webac / enabled true Whether WebAC authorization is enabled
webac / cacheSize 1000 The number of entries stored in an auth cache
webac / cacheExpireSeconds 600 The number of seconds to keep cached auth queries
jwt / enabled true Whether jwt authentication is enabled
jwt / key (none) The signing key for JWT tokens
jwt / keyStore (none) A file path for a local keystore
jwt / keyStorePassword (none) A password for the local keystore
jwt / keyIds (none) A list of acceptable key IDs
jwt / jwks (none) The URL for a JWKS document
basic / enabled true Whether basic authentication is enabled
basic / usersFile (none) The path to a file where user credentials are stored
realm trellis The authentication realm
cors:
    enabled: true
    allowOrigin:
        - "*"
    allowMethods:
        - "GET"
        - "POST"
        - "PATCH"
    allowHeaders:
        - "Content-Type"
        - "Link"
    exposeHeaders:
        - "Link"
        - "Location"
    maxAge: 180
    allowCredentials: true
Name Default Description
enabled false Whether CORS is enabled
allowOrigin "*" A list of allowed origins
allowMethods "PUT", "DELETE", "PATCH", "GET", "HEAD", "OPTIONS", "POST" A list of allowed methods
allowHeaders "Content-Type", "Link", "Accept", "Accept-Datetime", "Prefer", "Slug" A list of allowed request headers
exposeHeaders "Content-Type", "Link", "Memento-Datetime", "Preference-Applied", "Location", "Accept-Patch", "Accept-Post", "Accept-Ranges", "ETag", "Vary" A list of allowed response headers
maxAge 180 The maximum age (in seconds) of pre-flight messages
allowCredentials true Whether the actual request can be made with credentials
cache:
    maxAge: 86400
    mustRevalidate: true
    noCache: false
Name Default Description
maxAge 86400 The value of the Cache-Control: max-age= response header
mustRevalidate true Whether to include a Cache-Controle: must-revalidate directive
noCache false Whether to include a Cache-Control: no-cache directive
jsonld:
    contextWhitelist:
        - "http://example.com/context.json"
    contextDomainWhitelist:
        - "http://example.com/"
    cacheExpireHours: 24
    cacheSize: 100
Name Default Description
contextWhitelist an empty list a user-supplied whitelist of valid JSON-LD profile values
contextDomainWhitelist an empty list a user-supplied whitelist of domains for valid JSON-LD profile values
cacheExpireHours 24 The number of hours that a JSON-LD profile value will be stored in a cache.
cacheSize 100 The number of entries stored in the JSON-LD profile cache.

Alternate HTML Representation

The Trellis RDFa module includes a configurable HTMLSerializer. It accepts the following optional asset configuration options.

For example, to configure the HTML to produce a table, one can opt to use the resource-table.mustache template.
With this tabular HTML, one could then add sorting and search filter functionality with a JS library.

assets:
    template: org/trellisldp/rdfa/resource-table.mustache
    icon: "http://example.org/image.icon"
    js:
        - "https://unpkg.com/vanilla-datatables@latest/dist/vanilla-dataTables.min.js"
        - "http://example.org/table.js"
    css:
        - "http://example.org/styles1.css"
        - "http://example.org/styles2.css"
Name Default Description
template org/trellisldp/rdfa/resource.mustache an HTML template located in the org.trellisldp.rdfa module classpath
icon none a URL to a favicon
js none a list of URLs for javascript assets
css none a list of URLs for CSS assets

HTTP/2

Trellis supports the HTTP/2 protocol. For more information about how to enable HTTP/2 with Trellis, please refer to the dropwizard documentation. In particular, an h2 connector type must be used, typically with a corresponding TLS configuration.

HTTP/2 Java Implementation Notes:

To use HTTP/2 over TLS with JRE 1.8 requires the alpn-boot library to be in the bootclasspath.

If using the Linux distribution, you can set an environment variable:

JAVA_OPTS=-Xbootclasspath/p:/path/to/alpn-boot.jar

For JDK 9+, you can simply add a dependency like this to the trellis-app-triplestore build.gradle:

jettyAlpnServerVersion = '9.4.8.v20171121'
compile("org.eclipse.jetty:jetty-alpn-java-server:$jettyAlpnServerVersion")

Metrics reporting

Application metrics can be configured by defining a frequency and a reporter. For more information about configuring these reports, please refer to the dropwizard metrics configuration reference.

You can’t perform that action at this time.