flatten docs, no details

This commit is contained in:
ruslandoga 2024-05-10 16:15:31 +07:00 committed by ruslandoga
parent 2703326e60
commit 41b38bd384
2 changed files with 220 additions and 119 deletions

1
.prettierignore Normal file
View File

@ -0,0 +1 @@
*

338
README.md
View File

@ -15,7 +15,6 @@
**Contact**:
- For release announcements please go to [GitHub releases.](https://github.com/plausible/analytics/releases)
- For a question or advice please go to [GitHub discussions.](https://github.com/plausible/analytics/discussions/categories/self-hosted-support)
---
@ -36,7 +35,7 @@ Plausible Community Edition (or CE for short) is designed to be self-hosted thro
### Requirements
The only thing you need to install Plausible CE is a server with Docker. The server must have a CPU with x86_64 or arm64 architecture and support for SSE 4.2 or equivalent NEON instructions. We recommend using a minimum of 4GB of RAM but the requirements will depend on your site traffic.
The only thing you need to install Plausible CE is a server with Docker. The server must have a CPU with x86_64 or arm64 architecture and support for SSE 4.2 or equivalent NEON instructions. We recommend using a minimum of 4GB of RAM but the requirements will depend on your site traffic.
We've tested this on [Digital Ocean](https://m.do.co/c/91569eca0213) (affiliate link) but any hosting provider works. If your server doesn't come with Docker pre-installed, you can follow [their docs](https://docs.docker.com/get-docker/) to install it.
@ -48,9 +47,7 @@ To get started quickly, clone the [plausible/community-edition](https://github.c
<sub><kbd>console</kbd></sub>
```console
$ mkdir hosting
$ cd hosting
$ git clone https://github.com/plausible/community-edition .
$ git clone https://github.com/plausible/community-edition hosting
Cloning into 'community-edition'...
remote: Enumerating objects: 280, done.
remote: Counting objects: 100% (146/146), done.
@ -58,18 +55,18 @@ remote: Compressing objects: 100% (74/74), done.
remote: Total 280 (delta 106), reused 86 (delta 71), pack-reused 134
Receiving objects: 100% (280/280), 69.44 KiB | 7.71 MiB/s, done.
Resolving deltas: 100% (136/136), done.
$ ls
$ ls hosting
README.md clickhouse/ docker-compose.yml images/ plausible-conf.env reverse-proxy/ upgrade/
```
In the downloaded directory you'll find two important files:
- [`docker-compose.yml`](https://github.com/plausible/hosting/blob/master/docker-compose.yml) - installs and orchestrates networking between your Plausible CE server, Postgres database, Clickhouse database (for stats), and an SMTP server.
- [`plausible-conf.env`](https://github.com/plausible/hosting/blob/master/plausible-conf.env) - configures the Plausible server itself. Full configuration options are documented [below.](#configure)
- [docker-compose.yml](./docker-compose.yml) — installs and orchestrates networking between your Plausible CE server, Postgres database, Clickhouse database (for stats), and an SMTP server.
- [plausible-conf.env](./plausible-conf.env) — configures the Plausible server itself. Full configuration options are documented [below.](#configure)
Right now the latter looks like this:
<sub><kbd>[plausible-conf.env](https://github.com/plausible/hosting/blob/master/plausible-conf.env)</kbd></sub>
<sub><kbd>[plausible-conf.env](./plausible-conf.env)</kbd></sub>
```env
BASE_URL=replace-me
SECRET_KEY_BASE=replace-me
@ -77,7 +74,9 @@ SECRET_KEY_BASE=replace-me
Let's do as it asks and populate these required environment variables with our own values.
First we generate the [`SECRET_KEY_BASE`](#secret_key_base) using `openssl`
#### Required configuration
First we generate the [secret key base](#secret_key_base) using OpenSSL:
<sub><kbd>console</kbd></sub>
```console
@ -85,7 +84,7 @@ $ openssl rand -base64 48
GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz
```
And then we decide on the [`BASE_URL`](#base_url) where the instance would be accessible. Let's assume we choose `http://plausible.example.com`
And then we decide on the [base URL](#base_url) where the instance would be accessible:
<sub><kbd>plausible-conf.env</kbd></sub>
```diff
@ -97,11 +96,19 @@ And then we decide on the [`BASE_URL`](#base_url) where the instance would be ac
We can start our instance now but the requests would be served over HTTP. Not cool! Let's configure [Caddy](https://caddyserver.com) to enable HTTPS.
<details><summary>Don't need reverse proxy?</summary>
#### Caddy
If you're **opting out** of a reverse proxy and HTTPS, you'll need to adjust the Plausible service [configuration](https://github.com/plausible/community-edition/blob/v2.0.0/docker-compose.yml#L38) to ensure it's not limited to localhost (127.0.0.1). This change allows the service to be accessible from any network interface:
> [!TIP]
> For other reverse-proxy setups please see [reverse-proxy](./reverse-proxy) docs.
<sub><kbd>[docker-compose.yml](https://github.com/plausible/community-edition/blob/v2.0.0/docker-compose.yml#L38)</kbd></sub>
<details>
<summary>Don't need reverse proxy?</summary>
---
If you're **opting out** of a reverse proxy and HTTPS, you'll need to adjust the Plausible service [configuration](./docker-compose.yml#L38) to ensure it's not limited to localhost (127.0.0.1). This change allows the service to be accessible from any network interface:
<sub><kbd>[docker-compose.yml](./docker-compose.yml#L38)</kbd></sub>
```diff
plausible:
ports:
@ -109,17 +116,15 @@ plausible:
+ - 8000:8000
```
---
</details>
<!-- TODO note about CloudFlare -->
> For other reverse-proxy setups please see [reverse-proxy](https://github.com/plausible/hosting/tree/master/reverse-proxy) docs.
First we need to point DNS records for `plausible.example.com` to the IP address of the instance. This is needed for Caddy to issue the TLS certificates.
First we need to point DNS records for our base URL to the IP address of the instance. This is needed for Caddy to issue the TLS certificates.
Then we need to let Caddy know the domain name for which to issue the TLS certificate and the service to redirect the requests to.
<sub><kbd>[reverse-proxy/docker-compose.caddy-gen.yml](https://github.com/plausible/hosting/blob/master/reverse-proxy/docker-compose.caddy-gen.yml)</kbd></sub>
<sub><kbd>[reverse-proxy/docker-compose.caddy-gen.yml](./reverse-proxy/docker-compose.caddy-gen.yml)</kbd></sub>
```diff
plausible:
labels:
@ -130,7 +135,7 @@ Then we need to let Caddy know the domain name for which to issue the TLS certif
+ virtual.tls-email: "admin@plausible.example.com"
```
Finally we need to update `BASE_URL` to use `https://` scheme.
Finally we need to update the base URL to use HTTPS scheme.
<sub><kbd>plausible-conf.env</kbd></sub>
```diff
@ -141,6 +146,8 @@ Finally we need to update `BASE_URL` to use `https://` scheme.
Now we can start everything together.
#### Launch
<sub><kbd>console</kbd></sub>
```console
$ docker compose -f docker-compose.yml -f reverse-proxy/docker-compose.caddy-gen.yml up -d
@ -157,17 +164,18 @@ $ docker compose -f docker-compose.yml -f reverse-proxy/docker-compose.caddy-gen
✔ Container caddy-gen Started
```
It takes some time to start PostgreSQL and ClickHouse, create the databases, and run the migrations. After about fifteen seconds you should be able to access your instance at `BASE_URL` and see the registration screen for the admin user.
It takes some time to start PostgreSQL and ClickHouse, create the databases, and run the migrations. After about fifteen seconds you should be able to access your instance at the base URL and see the registration screen for the admin user.
In case something feels off, make sure to check out the logs with <kbd>docker compose logs</kbd> and start a [GitHub discussion.](https://github.com/plausible/analytics/discussions/categories/self-hosted-support)
> [!TIP]
> If something feels off, make sure to check out the logs with <kbd>docker compose logs</kbd> and start a [GitHub discussion.](https://github.com/plausible/analytics/discussions/categories/self-hosted-support)
Happy hosting!
🎉 Happy hosting! 🚀
Next we'll go over how to upgrade the instance when a new release comes out, more things to configure, and how to integrate with Google and others!
## Upgrade
Each new [release](https://github.com/plausible/analytics/releases/tag/v2.0.0) contains information on how to upgrade to it from the previous version. This section outlines the
Each new [release](https://github.com/plausible/analytics/releases/tag/v2.0.0) contains information on how to upgrade to it from the previous version. This section outlines the
general steps and explains the versioning.
### Version management
@ -176,8 +184,8 @@ Plausible CE follows [semantic versioning:](https://semver.org/) `MAJOR.MINOR.PA
You can find available Plausible versions on [DockerHub](https://hub.docker.com/r/plausible/analytics). The default `latest` tag refers to the latest stable release tag. You can also pin your version:
- `plausible/analytics:v2` pins the major version to `2` but allows minor and patch version upgrades
- `plausible/analytics:v2.0` pins the minor version to `2.0` but allows only patch upgrades
- <kbd>plausible/analytics:v2</kbd> pins the major version to 2 but allows minor and patch version upgrades
- <kbd>plausible/analytics:v2.0</kbd> pins the minor version to 2.0 but allows only patch upgrades
None of the functionality is backported to older versions. If you wish to get the latest bug fixes and security updates you need to upgrade to a newer version.
@ -186,8 +194,9 @@ as an internal API and therefore schema changes aren't considered a breaking cha
We recommend to pin the major version instead of using `latest`. Either way the general flow for upgrading between minor version would look like this:
<sub><kbd>console</kbd></sub>
```console
$ cd hosting
$ cd hosting # or wherever you cloned this repo
$ docker compose stop plausible
[+] Running 1/1
✔ Container hosting-plausible-1 Stopped
@ -218,28 +227,34 @@ $ docker rmi 5e1e0047953a
Untagged: plausible/analytics:v1.5
Untagged: plausible/analytics@sha256:365124b00f103ac40ce3c64cd49a869d94f2ded221d9bb7900be1cecfaf34acf
Deleted: sha256:5e1e0047953afc179ee884389e152b3f07343fb34e5586f9ecc2f33c6ba3bcaa
// etc.
...
```
> [!TIP]
> You can omit <kbd>-f docker-compose.yml -f reverse-proxy/docker-compose.caddy-gen.yml</kbd> if you are not using Caddy.
Changes in major versions would involve performing a data migration (e.g.[v2.0.0](https://github.com/plausible/analytics/releases/tag/v2.0.0)) or some other extra step.
Changes in major versions would involve performing a data migration (e.g. [v2.0.0](https://github.com/plausible/analytics/releases/tag/v2.0.0)) or some other extra step.
## Configure
Plausible is configured with environment variables, by default supplied via [<kbd>plausible-conf.env</kbd>](https://github.com/plausible/hosting/blob/master/plausible-conf.env) [env_file.](https://github.com/plausible/hosting/blob/bb6decee4d33ccf84eb235b6053443a01498db53/docker-compose.yml#L38-L39)
Plausible is configured with environment variables, by default supplied via [plausible-conf.env](./plausible-conf.env) [env_file.](./docker-compose.yml#L38-L39)
> Note that if you start a container with one set of ENV vars and then update the ENV vars and restart the container, they won't take effect due to the immutable nature of the containers. The container needs to be recreated.
> [!WARNING]
> Note that if you start a container with one set of ENV vars and then update the ENV vars and restart the container, they won't take effect due to the immutable nature of the containers. The container needs to be **recreated.**
Here's the minimal <kbd>plausible-conf.env</kbd> we got from [Quick start.](#quick-start)
#### Example configurations
Here's the minimal configuration file we got from the [quick start:](#quick-start)
<sub><kbd>plausible-conf.env</kbd></sub>
```env
BASE_URL=https://plausible.example.com
SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz
```
And here's <kbd>plausible-conf.env</kbd> with some extra configuration
And here's a configuration with some extra options provided:
<sub><kbd>plausible-conf.env</kbd></sub>
```env
BASE_URL=https://plausible.example.com
SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz
@ -256,22 +271,23 @@ Here're the currently supported ENV vars:
### Required
#### `BASE_URL`
#### BASE_URL
Configures the base URL to use in link generation, doesn't have any defaults and needs to be provided in the ENV vars
<sub><kbd>plausible-conf.env</kbd></sub>
```env
BASE_URL=https://example.fun
BASE_URL=https://plausible.example.com
```
> [!NOTE]
> In production systems, this should be your ingress host (CDN or proxy).
---
#### `SECRET_KEY_BASE`
#### SECRET_KEY_BASE
Configures the secret used for sessions in the dashboard, doesn't have any defaults and needs to be provided in the ENV vars, can be generated with `openssl rand -base64 48`
Configures the secret used for sessions in the dashboard, doesn't have any defaults and needs to be provided in the ENV vars, can be generated with OpenSSL:
<sub><kbd>console</kbd></sub>
```console
@ -282,16 +298,14 @@ GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz
<sub><kbd>plausible-conf.env</kbd></sub>
```env
SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz
``````
```
> ⚠️ Don't use this exact value or someone would be able to sign a cookie with `user_id=1` and log in as the admin!
> [!WARNING]
> Don't use this exact value or someone would be able to sign a cookie with `user_id=1` and log in as the admin!
### Optional
### Registration
<details>
<summary>Registration</summary>
#### `DISABLE_REGISTRATION`
#### DISABLE_REGISTRATION
Default: `true`
@ -299,47 +313,48 @@ Restricts registration of new users. Possible values are `true` (full restrictio
---
#### `ENABLE_EMAIL_VERIFICATION`
#### ENABLE_EMAIL_VERIFICATION
Default: `false`
When enabled, new users need to verify their email addressby following a link delivered to their mailbox. Please configure your server for SMTP to receive this email. You can find Plausible's SMTP configuration options under "Email" below.
When enabled, new users need to verify their email addressby following a link delivered to their mailbox. Please configure your server for SMTP to receive this email. You can find Plausible's SMTP configuration options under [below.](#email)
If something went wrong you can run this command to verify all users in the database:
<sub><kbd>console</kbd></sub>
```console
$ cd hosting
$ cd hosting # or wherever you cloned this repo
$ docker compose exec plausible_db psql -U postgres -h localhost -d plausible_db -c "UPDATE users SET email_verified = true;"
```
</details>
<details>
<summary>Web</summary>
### Web
#### `LISTEN_IP`
#### LISTEN_IP
Default: `0.0.0.0`
Configures the IP address to bind the listen socket for the web server.
> [!WARNING]
> Note that setting it to `127.0.0.1` in a container would make the web server unavailable from outside the container.
---
#### `PORT`
#### PORT
Default: `8000`
Configures the port to bind the listen socket for the web server.
</details>
<details>
<summary>Database</summary><br/>
---
### Database
Plausible uses PostgreSQL for storing user data and ClickhouseDB for analytics data. Use the following variables to configure them.
#### `DATABASE_URL`
---
#### DATABASE_URL
Default: `postgres://postgres:postgres@plausible_db:5432/plausible_db`
@ -347,7 +362,7 @@ Configures the URL for PostgreSQL database.
---
#### `CLICKHOUSE_DATABASE_URL`
#### CLICKHOUSE_DATABASE_URL
Default: `http://plausible_events_db:8123/plausible_events_db`
@ -355,7 +370,7 @@ Configures the URL for ClickHouse database.
---
#### `ECTO_IPV6`
#### ECTO_IPV6
Enables Ecto to use IPv6 when connecting to the PostgreSQL database. Not set by default.
@ -366,7 +381,7 @@ ECTO_IPV6=true
---
#### `ECTO_CH_IPV6`
#### ECTO_CH_IPV6
Enables Ecto to use IPv6 when connecting to the ClickHouse database. Not set by default.
@ -375,13 +390,11 @@ Enables Ecto to use IPv6 when connecting to the ClickHouse database. Not set by
ECTO_CH_IPV6=true
```
</details>
<details>
<summary>Google</summary><br/>
### Google
For step-by-step integration with Google [see below.](#integrate)
For step-by-step integration with Google [see below.](#google-integration)
#### `GOOGLE_CLIENT_ID`
#### GOOGLE_CLIENT_ID
The Client ID from the Google API Console for your project. Not set by default.
@ -392,7 +405,7 @@ GOOGLE_CLIENT_ID=140927866833-002gqg48rl4iku76lbkk0qhu0i0m7bia.apps.googleuserco
---
#### `GOOGLE_CLIENT_SECRET`
#### GOOGLE_CLIENT_SECRET
The Client Secret from the Google API Console for your project. Not set by default.
@ -401,23 +414,13 @@ The Client Secret from the Google API Console for your project. Not set by defau
GOOGLE_CLIENT_SECRET=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
```
</details>
<details>
<summary>IP Geolocation</summary><br/>
### IP Geolocation
Plausible CE uses the country database created by [db-ip](https://db-ip.com/) for enriching analytics data with visitor countries. The database is shipped within the container image and country data collection happens automatically.
Optionally, you can provide a different database. For example, you can use [MaxMind](https://www.maxmind.com) services and enable city-level geolocation.
Optionally, you can provide a different database. For example, you can use [MaxMind](https://www.maxmind.com) services and enable city-level geolocation:
| Parameter | Default | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `IP_GEOLOCATION_DB` | /app/lib/plausible-0.0.1/priv/geodb/dbip-country.mmdb.gz | This database is used to lookup GeoName IDs for IP addresses. If not set, Plausible defaults to the [file](https://github.com/plausible/analytics/blob/v2.0.0/Dockerfile#L47) shipped within the container image. |
| `GEONAMES_SOURCE_FILE` | [/app/lib/location-0.1.0/priv/geonames.lite.csv](https://github.com/plausible/location/blob/main/priv/geonames.lite.csv) | This file is used to turn GeoName IDs into human readable strings for display on the dashboard. Defaults to the one shipped within the container image. |
| `MAXMIND_LICENSE_KEY` | -- | If set, this ENV variable takes precedence over `IP_GEOLOCATION_DB` and makes Plausible download (and keep up to date) a free MaxMind GeoLite2 MMDB of the selected edition. [See below](#integrate) for integration instructions. |
| `MAXMIND_EDITION` | <kbd>GeoLite2-City</kbd> | MaxMind database edition to use (only if `MAXMIND_LICENSE_KEY` is set) |
<sub>Example <kbd>plausible-conf.env</kbd> with MaxMind configured</sub>
<sub><kbd>plausible-conf.env</kbd></sub>
```env
BASE_URL=https://plausible.example.com
SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz
@ -425,46 +428,141 @@ MAXMIND_LICENSE_KEY=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
MAXMIND_EDITION=GeoLite2-City
```
</details>
<details><summary>Email</summary><br/>
---
Plausible CE uses a SMTP server to send transactional emails e.g. account activation, password reset. In addition, it sends non-transactional emails like weekly or monthly reports.
#### IP_GEOLOCATION_DB
| Parameter | Default | Description |
| ----------------------- | -------------------------------- | ------------------------------------------------------------------------------- |
| `MAILER_EMAIL` | <kbd>hello@plausible.local</kbd> | The email id to use for as _from_ address of all communications from Plausible. |
| `MAILER_NAME` | -- | The display name for the sender (_from_). |
| `SMTP_HOST_ADDR` | <kbd>localhost</kbd> | The host address of your SMTP server. |
| `SMTP_HOST_PORT` | <kbd>25</kbd> | The port of your SMTP server. |
| `SMTP_USER_NAME` | -- | The username/email in case SMTP auth is enabled. |
| `SMTP_USER_PWD` | -- | The password in case SMTP auth is enabled. |
| `SMTP_HOST_SSL_ENABLED` | <kbd>false</kbd> | If SSL is enabled for SMTP connection |
| `SMTP_RETRIES` | <kbd>2</kbd> | Number of retries to make until mailer gives up. |
Default: `/app/lib/plausible-0.0.1/priv/geodb/dbip-country.mmdb.gz`
Alternatively, you can use other [Bamboo Adapters](https://hexdocs.pm/bamboo/readme.html#available-adapters) such as Postmark, Mailgun, Mandrill or Send Grid to send transactional emails. In this case, use the following parameters:
This database is used to lookup GeoName IDs for IP addresses. If not set, defaults to the [file](https://github.com/plausible/analytics/blob/v2.0.0/Dockerfile#L47) shipped within the container image.
| Parameter | Default | Description |
| ------------------ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MAILER_ADAPTER` | <kbd>Bamboo.SMTPAdapter</kbd> | Instead of the default, replace this with <kbd>Bamboo.PostmarkAdapter</kbd>, <kbd>Bamboo.MailgunAdapter</kbd>, <kbd>Bamboo.MandrillAdapter</kbd> or <kbd>Bamboo.SendGridAdapter</kbd> and add the appropriate variables below |
| `POSTMARK_API_KEY` | -- | Enter your Postmark API key. |
| `MAILGUN_API_KEY` | -- | Enter your Mailgun API key. |
| `MAILGUN_DOMAIN` | -- | Enter your Mailgun domain. |
| `MAILGUN_BASE_URI` | -- | This is optional. Mailgun makes a difference in the API base URL between sender domains from within the EU and outside. By default, the base URL is set to <kbd>https://api.mailgun.net/v3</kbd>. To override this you can pass <kbd>https://api.eu.mailgun.net/v3</kbd> if you are using an EU domain. |
| `MANDRILL_API_KEY` | -- | Enter your Mandrill API key. |
| `SENDGRID_API_KEY` | -- | Enter your SendGrid API key. |
---
In case you are using Postmark, you have to set the `MAILER_EMAIL` variable which needs to be configured in PostmarkApps sender signatures.
#### GEONAMES_SOURCE_FILE
</details>
Default: [/app/lib/location-0.1.0/priv/geonames.lite.csv](https://github.com/plausible/location/blob/main/priv/geonames.lite.csv)
This file is used to turn GeoName IDs into human readable strings for display on the dashboard. Defaults to the one shipped within the container image.
---
#### MAXMIND_LICENSE_KEY
If set, this ENV variable takes precedence over [IP_GEOLOCATION_DB](#ip_geolocation_db) and makes Plausible download (and keep up to date) a free MaxMind GeoLite2 MMDB of the selected edition. [See below](#maxmind-integration) for integration instructions.
---
#### MAXMIND_EDITION
Default: `GeoLite2-City`
MaxMind database edition to use (only if [MAXMIND_LICENSE_KEY](#maxmind_license_key) is set)
### Email
Plausible CE sends transactional emails e.g. account activation, password reset. In addition, it sends non-transactional emails like weekly or monthly reports.
It uses SMTP with a [relay](./docker-compose.yml#L3-L5) by default. Alternatively, you can use other [services](https://hexdocs.pm/bamboo/readme.html#available-adapters) such as Postmark, Mailgun, Mandrill or Send Grid to send emails.
#### MAILER_ADAPTER
Default: `Bamboo.SMTPAdapter`
Instead of the default, you can replace this with <kbd>Bamboo.PostmarkAdapter</kbd>, <kbd>Bamboo.MailgunAdapter</kbd>, <kbd>Bamboo.MandrillAdapter</kbd> or <kbd>Bamboo.SendGridAdapter</kbd> and add the appropriate variables.
#### MAILER_EMAIL
Default: `hello@plausible.local`
The email id to use for as _from_ address of all communications from Plausible.
#### MAILER_NAME
The display name for the sender (_from_).
---
#### SMTP_HOST_ADDR
Default: [`mail`](./docker-compose.yml#L3-L5)
The host address of your SMTP relay.
#### SMTP_HOST_PORT
Default: `25`
The port of your SMTP relay.
#### SMTP_USER_NAME
The username/email in case SMTP auth is required on your SMTP relay.
#### SMTP_USER_PWD
The password in case SMTP auth is required on your SMTP relay.
#### SMTP_HOST_SSL_ENABLED
Default: `false`
Configures whether SMTPS (SMTP over SSL) is enabled for SMTP connection, e.g. when you use port 465.
#### SMTP_RETRIES
Default: `2`
Number of retries to make until mailer gives up.
---
#### POSTMARK_API_KEY
Enter your Postmark API key.
> [!NOTE]
> You also have to set the [MAILER_EMAIL](#mailer_email) variable which needs to be configured in PostmarkApps sender signatures.
---
#### MAILGUN_API_KEY
Enter your Mailgun API key.
#### MAILGUN_DOMAIN
Enter your Mailgun domain.
#### MAILGUN_BASE_URI
Default: `https://api.mailgun.net/v3`
Mailgun makes a difference in the API base URL between sender domains from within the EU and outside. By default, the base URL is set to <kbd>https://api.mailgun.net/v3</kbd>. To override this you can pass <kbd>https://api.eu.mailgun.net/v3</kbd> if you are using an EU domain.
---
#### MANDRILL_API_KEY
Enter your Mandrill API key.
---
#### SENDGRID_API_KEY
Enter your SendGrid API key.
## Integrate
<details>
<summary>Google</summary>
### Google integration
Integrating with Google either to get search keywords for hits from Google search or for imports from Universal Analytics can be frustrating.
The following screenshot-annotated guide shows how to do it all in an easy way: follow the Google-colored arrows.
The following screenshot-annotated guide shows how to do it all in an easy way: just follow the Google-colored arrows!
<details>
<summary><b>View the guide</b></summary>
---
Here's the outline of what we'll do:
@ -481,6 +579,8 @@ Here's the outline of what we'll do:
- [Enable APIs for exports on Google Cloud](#enable-apis-for-exports-on-google-cloud)
- [Import into Plausible](#import-into-plausible)
---
### Set up OAuth on Google Cloud
#### Select or create a Google Cloud project
@ -563,11 +663,11 @@ Pick <kbd>Web application</kbd> for the application type, type the name for the
<img src="./images/3-oauth-client-create.png">
That redirect URL should be `/auth/google/callback` on your Plausible instance's [<kbd>BASE_URL</kbd>](https://github.com/plausible/hosting/blob/bb6decee4d33ccf84eb235b6053443a01498db53/plausible-conf.env#L1)
That redirect URL should be `/auth/google/callback` on your Plausible instance's [<kbd>BASE_URL</kbd>](./plausible-conf.env#L1)
<img src="./images/3-oauth-client-created.png">
Copy these to your [<kbd>plausible-conf.env</kbd>](https://github.com/plausible/hosting/blob/master/plausible-conf.env) and make sure to recreate the `plausible` container since the ENV vars provided on startup get "baked in"
Copy these to your [<kbd>plausible-conf.env</kbd>](./plausible-conf.env) and make sure to recreate the `plausible` container since the ENV vars provided on startup get "baked in"
<sub><kbd>plausible-conf.env</kbd></sub>
```env
@ -603,7 +703,7 @@ $ docker compose exec plausible sh -c 'echo $GOOGLE_CLIENT_ID'
Did you notice that during OAuth application registratation there was a note about Authorized URLs saying that they need to be verified? Nevermind, we are doing it now.
Start by navigating to [Google Search Console page.](http://search.google.com/u/1/search-console/welcome)
Start by navigating to [Google Search Console page.](http://search.google.com/u/1/search-console/welcome)
Once there, either ensure that you've already verified your domain by checking the properties in the <kbd>Select property</kbd> dropdown on the left or pick one of the two ways to verify it. I only have screenshots for the "Domain" type so that's what I'm picking.
@ -687,7 +787,7 @@ Go to the site settings on your Plausible dashboard.
<img src="./images/6-plausible-settings-pick.png">
In the <kbd>General</kbd> settings section scroll down to <kbd>Data Import from Google Analytics</kbd> and press <kbd>Continue with Google</kbd> button.
In the <kbd>General</kbd> settings section scroll down to <kbd>Data Import from Google Analytics</kbd> and press <kbd>Continue with Google</kbd> button.
> If you see a warning instead, that means you haven't set the <kbd>GOOGLE_CLIENT_ID</kbd> and <kbd>GOOGLE_CLIENT_SECRET</kbd> environment variables [correctly.](#issue-an-oauth-client-and-key-for-that-application)
@ -707,14 +807,14 @@ Pick the view to import and then follow the Plausible directions.
You'll receive an email once the data is imported.
</details>
<details>
<summary>MaxMind</summary>
To use MaxMind you need to create an account [here.](https://www.maxmind.com/en/geolite2/signup) Once you have your account details, you can add `MAXMIND_LICENSE_KEY` and `MAXMIND_EDITION` environmental valiables to your <kbd>plausible-conf.env</kbd> and the databases would be automatically downloaded and kept up to date. Note that using city-level databases like MaxMind's `GeoLite2-City` requires ~1GB more RAM.
---
</details>
### MaxMind integration
To use MaxMind you need to create an account [here.](https://www.maxmind.com/en/geolite2/signup) Once you have your account details, you can add [MAXMIND_LICENSE_KEY](#maxmind_license_key) and [MAXMIND_EDITION](#maxmind_edition) environmental valiables to your [plausible-conf.env](./plausible-conf.env) and the databases would be automatically downloaded and kept up to date. Note that using city-level databases like MaxMind's GeoLite2-City requires ~1GB more RAM.
## FAQ
<details>
@ -724,7 +824,7 @@ You can starts an Interactive Elixir session from within the `plausible` contain
<sub><kbd>console</kbd></sub>
```console
$ cd hosting
$ cd hosting # or wherever you cloned this repo
$ docker compose exec plausible bin/plausible remote
```
```elixir
@ -752,7 +852,7 @@ You can starts a `clickhouse client` session from within the `plausible_events_d
<sub><kbd>console</kbd></sub>
```console
$ cd hosting
$ cd hosting # or wherever you cloned this repo
$ docker compose exec plausible_events_db clickhouse client --database plausible_events_db
```
```sql
@ -790,7 +890,7 @@ You can starts a `psql` session from within the `plausible_db` container:
<sub><kbd>console</kbd></sub>
```console
$ cd hosting
$ cd hosting # or wherever you cloned this repo
$ docker compose exec plausible_db psql -U postgres -h localhost -d plausible_db
```
```sql