Skip to main content

Configuration

Configuration Formats​

The Xillio Link Redirector supports multiple configuration formats; YAML, JSON, and environment variables.

Loading Configuration files​

./link-redirector -c config.yml
./link-redirector -c config.json
./link-redirector -c ~/some-other/folder/config.yml

Using Docker Volumes​

docker run -p 80:80 -p 443:443 -v ./path/to/config.yml:/app/config.yml xillio/link-redirector

Using Volumes in Docker Compose​

version: '3.3'

services:
xlr:
image: xillio/link-redirector
ports:
- 80:80
- 443:443
volumes:
- ./path/to/config.yml:/app/config.yml

Configuration through Environment Variables​

The Xillio Link Redirector can be configured using environment variables. This approach simplifies the deployment of the application to different environments, such as Docker and Kubernetes. It can replace a configuration file altogether.

To configure the Xillio Link Redirector using environment variables, follow these steps:

1. Identify the Required Environment Variables​

The first step is to identify the variables that need modification. For instance, a common use case is to set the application's license key. The environment variable to set for this configuration item would be XLR_LICENSE_KEY.

Environment variable should have the prefix XLR_, followed by the configuration group (similar to the configuration file), and then the property. Here are some examples:

Environment VariableKey in Configuration File
XLR_API_PORTapi.port
XLR_DATABASE_TYPEdatabase.type
XLR_DATABASE_URLdatabase.url
XLR_LOGGER_TYPElogger.type

2. Set the Environment Variables​

In most cases, you can set environment variables in the terminal or command prompt. For example, if you're using a Unix-like operating system, use the following command to set environment variables:

export XLR_LICENSE_KEY=value

If you're using a Windows operating system, you can set environment variables using the System Properties window. To access this window, navigate to Control Panel > System and Security > System > Advanced system settings > Environment Variables.

3. (Re)Start the Application​

After setting the environment variables, start the application. The configuration options should be applied automatically.

Example Configuration​

The following configuration is a very verbose version of the configuration file, with explanations on what each individual option is for.

config.yml
# Information on how the Xillio Link Redirector should act and be exposed towards the outside world
license:
key: YOUR-KEY-HERE

logger:
type: simple # The type of logger to use. choose from `simple`, `json`, or `void` (default: simple)
showStackTrace: false # Print the stack trace to stdout (default: false)
levels: # List of log-levels that should be shown. (default: all levels)
- audit # Possible values are ['trace', 'audit', 'http', 'debug', 'info', 'warn', 'error']
- http
- info
- warn
- error

proxy:
port: 80 # The port to use for HTTP connections (default: 80)
requestLogging: true # Enable logging incoming request to the console (default: false)
requestMonitoring: true # Enable measuring request data to a metric service (default: false)

# (Optional) Options for SSL connections.
# If `httpsPort` is defined, the `keyFile` and `certificateFile` also need to be specified.
httpsPort: 443 # The port to use for HTTPS connections (default: 443)
keyFile: ./certs/localhost.key # The path towards your certificate key file
certificateFile: ./certs/localhost.cert # The path towards your certificate file
# caFile: ./certs/rootCA.cert # (Optional) Override the root CA to use
forceHttps: true # Redirect all incoming HTTP request towards the HTTPS ports (default: false)

# (Optional) Additional configuration
# timeout: 10000 # Timeout for proxied request in milli seconds (default: 10000)
# addForwardedForHeaders: false # Add all headers of the incoming request to the proxied request (default: false)
# acceptUntrustedProxyTLS: false # Allow self-signed certificates for proxied requests (default: false)
# includeIP: false # Include the IP address of the client in the log (default: false)
# logProxyRequests: false # Log the proxied requests (default: false)
# verboseProxyLogging: false # Log the proxied requests in detail (only works with `logProxyRequests`) (default: false)
# maxUrlLength: 256 # The maximum length of the URL (default: 256)
# queryParameterOrder: overwrite # The order of query parameters in the URL. Chose from `keep` or `overwrite`. (default: overwrite)

api:
port: 8080 # The port to use for HTTP connections (default: 8080)
requestLogging: true # Enable logging of incoming request to stdout (default: false)
requestMonitoring: true # Enable measuring of request data to a metric service (default: false)

# (Optional) Options for SSL connections.
# If `httpsPort` is defined, the `keyFile` and `certificateFile` also need to be specified.
httpsPort: 8443 # The port to use for HTTPS connections (default: 8443)
keyFile: ./certs/localhost.key # The path to your certificate key file
certificateFile: ./certs/localhost.cert # The path to your certificate file
# caFile: ./certs/rootCA.cert # (Optional) Override the root CA to use
forceHttps: true # Redirect all incoming HTTP request towards the HTTPS ports (default: false)

# basePath: /xlr/api # The base path for all api endpoints (default: /xlr/api)
# maxUrlLength: 256 # The maximum length of the URL (default: 256)
# includeIP: false # Include the IP address of the client in the log (default: false)

# Configuration on the database connection
database:
type: postgres
url: postgresql://postgres:example@db:5432/xlr

# (Optional) Configuration for the metrics service to use for request and performance metrics
metrics:
type: influx
url: http://:development@metrics:8086
organization: xillio
performanceMonitoring: true # Enable measuring system performance to a metric service (default: false)