mirror of
https://github.com/chevereto/docker.git
synced 2025-12-16 13:09:47 +01:00
71 lines
1.7 KiB
Markdown
71 lines
1.7 KiB
Markdown
|
|
# CloudFlare
|
||
|
|
|
||
|
|
CloudFlare integration enables to automatically create hostnames (sub-domains) for a given DNS zone. It allows to create/destroy multiple hostnames associated with a Chevereto container running in the same server.
|
||
|
|
|
||
|
|
## How it works?
|
||
|
|
|
||
|
|
It creates CNAMEs pointing to an **A record** which points to the server. This enables CNAMEs to point to the same server IP by controlling just one record.
|
||
|
|
|
||
|
|
```plain
|
||
|
|
A demo.chevereto.cloud -> <SERVER IP>
|
||
|
|
CNAME user1.chevereto.cloud -> demo.chevereto.cloud
|
||
|
|
CNAME user2.chevereto.cloud -> demo.chevereto.cloud
|
||
|
|
...etc
|
||
|
|
```
|
||
|
|
|
||
|
|
## Setup
|
||
|
|
|
||
|
|
* Go to your CloudFlare domain DNS
|
||
|
|
* Create an **A record** pointing to server IP (DNS only, do not cache)
|
||
|
|
* Get an [API token](#cloudflare-token) for the DNS zone
|
||
|
|
* Copy [.env-stock](.env-stock) to `.env` and fill in the values
|
||
|
|
|
||
|
|
### .env file
|
||
|
|
|
||
|
|
```env
|
||
|
|
CLOUDFLARE_TOKEN=
|
||
|
|
CLOUDFLARE_ZONE_ID=
|
||
|
|
CLOUDFLARE_ACCOUNT_ID=
|
||
|
|
CLOUDFLARE_A_NAME=
|
||
|
|
```
|
||
|
|
|
||
|
|
### CloudFlare Token
|
||
|
|
|
||
|
|
`CLOUDFLARE_TOKEN`
|
||
|
|
|
||
|
|
* Go to [api-tokens](https://dash.cloudflare.com/profile/api-tokens) and go to **Create Token**
|
||
|
|
* Use template **Edit zone DNS**
|
||
|
|
* Permissions: **Zone DNS Edit**
|
||
|
|
* Resources: **Include Specific zone DOMAIN**
|
||
|
|
* Continue to summary and **Create Token**
|
||
|
|
|
||
|
|
### CloudFlare Zone/Account ID
|
||
|
|
|
||
|
|
You get these values from **domain overview**.
|
||
|
|
|
||
|
|
### CloudFlare A Name
|
||
|
|
|
||
|
|
`CLOUDFLARE_A_NAME`
|
||
|
|
|
||
|
|
The A record used to point CNAMEs generated by this project.
|
||
|
|
|
||
|
|
## Commands
|
||
|
|
|
||
|
|
**Note:** Following commands must run only after creating the [NAMESPACE](NAMESPACE.md).
|
||
|
|
|
||
|
|
### Destroy instance
|
||
|
|
|
||
|
|
Refer to [make destroy](DOCKER-COMPOSE.md#destroy).
|
||
|
|
|
||
|
|
### Create CNAME record
|
||
|
|
|
||
|
|
```sh
|
||
|
|
make cloudflare--create NAMESPACE=yourproject
|
||
|
|
```
|
||
|
|
|
||
|
|
### Delete CNAME record
|
||
|
|
|
||
|
|
```sh
|
||
|
|
make cloudflare--delete NAMESPACE=yourproject
|
||
|
|
```
|