Configuring the backend
Introduction
Commento's backend is configured by a set of environment variables. If you're executing the binary from the command line, you can set environment variables:
$ export COMMENTO_ORIGIN=http://commento.example.com # no whitespace around =
$ ./commento
If you're running Commento with Docker Compose, you can do this with the environment:
keyword as shown here. If you prefer plain Docker, the -e
flag sets environment variables, as shown here.
You can also configure Commento using a configuration file specified with COMMENTO_CONFIG_FILE
. You can find specifications for this file in the section on configuration files.
Confiuration settings
This should be set to the subdomain or the IP address hosting Commento. All API requests will go to this server. This may include subdirectories if Commento is hosted behind a reverse proxy, for example. Include the protocol in the value to use HTTP/HTTPS.
A PostgreSQL server URI, including the database name.
A configuration file for Commento. See the section on the configuration file for more details. Useful to store secrets and credentials. No config file will be loaded by default, if left unspecified.
The address to bind the Commento server to. Useful if the server has multiple network interfaces. If not specified, this value defaults to COMMENTO_ORIGIN
.
The port to bind the Commento server to. Defaults to 8080.
When in Docker
You don't need to set COMMENTO_BIND_ADDRESS
and COMMENTO_PORT
if you're running Commento in Docker. Instead, set the external bind address and port with Docker's -p
flag.
Useful if you'd like to use a CDN with Commento (like AWS Cloudfront, for example) for faster delivery of static assets. You must set the CDN's origin value as COMMENTO_ORIGIN
. If not specified, a CDN is not used.
Used to disable new dashboard registrations. Useful if you are the only person using Commento on your server. Does not impact the creation of accounts for your readers. Defaults to false.
If you want to store the binary in a different directory from the static assets, set this directory to point to the static assets (HTML, JS, CSS, email templates and database migrations). Defaults to the same directory as the binary.
If set to true, all static content will be served GZipped if the client's browser supports compression. Defaults to false.
SMTP credentials and configuration the server should use to send emails. By default, all settings are empty and email features such as email notification and reset password are turned off.
COMMENTO_SMTP_PORT=587
COMMENTO_SMTP_USERNAME=example@gmail.com
COMMENTO_SMTP_PASSWORD=hunter2
COMMENTO_SMTP_FROM_ADDRESS=no-reply@example.com
Akismet API key. Create a key in your Akismet dashboard. By default, Akismet integration is turned off when this value is left empty.
Google OAuth configuration. Create a new project in the Google developer console to generate a set of credentials. By default, Google login is turned off when these values are left empty.
COMMENTO_GOOGLE_SECRET=XmaKz7gRkWw3MQgoAHmApuwb
GitHub OAuth configuration. Create a new OAuth app in GitHub developer settings to generate a set of credentials. By default, GitHub login is turned off when these values are left empty.
COMMENTO_GITHUB_SECRET=2fbdc6bdbb7c02119fd8fa70b7bdcfa7af8e2c
Google OAuth configuration. Create a new application in your GitLab settings to generate a set of credentials. By default, GitLab login is turned off when these values are left empty.
COMMENTO_GITLAB_SECRET=cf73049b59f63915bbdc318b1e2e8ecbbf5b8bafb18f1dd84d68adf8951b762b
Twitter OAuth configuration. Create an app in the Twitter developer dashboard to generate a set of credentials. By default, Twitter login is turned off when these values are left empty.
COMMENTO_TWITTER_SECRET=9j60WfN3LG6GAMbU5LCch1HQ6tT4ytiOzO95rM3DVD5dXHFT
Configuration file
With the COMMENTO_CONFIG_FILE
environment variable, you can specify a configuration file. You can use this file to store secrets and credentials without exposing them in the ./commento
invocation command. For example, a Docker secret can be created and mounted inside the container's filesystem, and Commento can read from this file.
Precedence
If you're specifying a configuration file using COMMENTO_CONFIG_FILE
, note that it will have lower precedence than environment variables.
The format for the configutation file is quite simple:
- Each configuration value is specified in one line
- Leading and trailing whitespaces on each line are ignored
- All lines starting with a
#
are treated as comments and ignored - All empty lines are ignored
- Each valid configuration line must contain an
=
symbol, specifyingCOMMENTO_KEY=value
Here is an example file:
# Set binding values
COMMENTO_ORIGIN=http://commento.example.com
COMMENTO_PORT=80
# Set PostgreSQL settings
COMMENTO_POSTGRES=postgres://commento:commento@127.0.0.1:5432/commento?sslmode=disable
# Set the SMTP credentials
COMMENTO_SMTP_HOST=smtp.gmail.com
COMMENTO_SMTP_PORT=587
COMMENTO_SMTP_USERNAME=example@gmail.com
COMMENTO_SMTP_PASSWORD=hunter2
COMMENTO_SMTP_FROM_ADDRESS=no-reply@commento.io
# Set Google OAuth credentials
COMMENTO_GOOGLE_KEY=204475040454-chmuz29vz2xldxnlcmnvbnrlbn.apps.googleusercontent.com
COMMENTO_GOOGLE_SECRET=09HTEVfU0VDUkVUPTh4
Say we store this file in /etc/commento.env
. Then, we can include this file when running Commento:
$ export COMMENTO_CONFIG_FILE=/etc/commento.env
$ ./commento