-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ElioDiNino/caddy
feat: Caddy configuration
- Loading branch information
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CLOUDFLARE_API_TOKEN="cloudflare_api_token" | ||
EXTERNAL_DOMAIN="internal.example.com" | ||
PROXY_HOST_URL="http://localhost" | ||
HOME_ASSISTANT_SUBDOMAIN="home-assistant" | ||
HOME_ASSISTANT_PORT="8123" | ||
SPOTIFY_DASH_FRONT_SUBDOMAIN="spotify-dashboard" | ||
SPOTIFY_DASH_FRONT_PORT="3000" | ||
SPOTIFY_DASH_BACK_SUBDOMAIN="spotify-dashboard-backend" | ||
SPOTIFY_DASH_BACK_PORT="8080" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(cloudflare) { | ||
tls { | ||
dns cloudflare {env.CLOUDFLARE_API_TOKEN} | ||
resolvers 1.1.1.1 | ||
} | ||
} | ||
|
||
# Home Assistant | ||
{$HOME_ASSISTANT_SUBDOMAIN}.{$EXTERNAL_DOMAIN} { | ||
reverse_proxy {$PROXY_HOST_URL}:{$HOME_ASSISTANT_PORT} | ||
import cloudflare | ||
} | ||
|
||
# Spotify Dashboard Frontend | ||
{$SPOTIFY_DASH_FRONT_SUBDOMAIN}.{$EXTERNAL_DOMAIN} { | ||
reverse_proxy {$PROXY_HOST_URL}:{$SPOTIFY_DASH_FRONT_PORT} | ||
import cloudflare | ||
} | ||
|
||
# Spotify Dashboard Backend | ||
{$SPOTIFY_DASH_BACK_SUBDOMAIN}.{$EXTERNAL_DOMAIN} { | ||
reverse_proxy {$PROXY_HOST_URL}:{$SPOTIFY_DASH_BACK_PORT} | ||
import cloudflare | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM caddy:2-builder AS builder | ||
|
||
# Build the Caddy with the Cloudflare DNS module | ||
RUN xcaddy build \ | ||
--with github.com/caddy-dns/cloudflare | ||
|
||
FROM caddy:2 | ||
|
||
COPY --from=builder /usr/bin/caddy /usr/bin/caddy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Caddy | ||
|
||
I use Caddy as a reverse proxy for my services. I use a custom build that includes the Cloudflare DNS plugin for automatic SSL certificate management. | ||
|
||
## Commands | ||
|
||
### Start services | ||
|
||
```sh | ||
docker-compose up -d | ||
``` | ||
|
||
### Stop services | ||
|
||
```sh | ||
docker-compose down | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
services: | ||
caddy: | ||
image: caddy:custom | ||
build: . | ||
restart: unless-stopped | ||
cap_add: | ||
- NET_ADMIN | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
- "443:443/udp" | ||
volumes: | ||
- ./Caddyfile:/etc/caddy/Caddyfile | ||
- caddy_data:/data | ||
- caddy_config:/config | ||
environment: | ||
CLOUDFLARE_API_TOKEN: ${CLOUDFLARE_API_TOKEN:?error} | ||
EXTERNAL_DOMAIN: ${EXTERNAL_DOMAIN:?error} | ||
PROXY_HOST_URL: ${PROXY_HOST_URL:?error} | ||
HOME_ASSISTANT_SUBDOMAIN: ${HOME_ASSISTANT_SUBDOMAIN:?error} | ||
HOME_ASSISTANT_PORT: ${HOME_ASSISTANT_PORT:?error} | ||
SPOTIFY_DASH_FRONT_SUBDOMAIN: ${SPOTIFY_DASH_FRONT_SUBDOMAIN:?error} | ||
SPOTIFY_DASH_FRONT_PORT: ${SPOTIFY_DASH_FRONT_PORT:?error} | ||
SPOTIFY_DASH_BACK_SUBDOMAIN: ${SPOTIFY_DASH_BACK_SUBDOMAIN:?error} | ||
SPOTIFY_DASH_BACK_PORT: ${SPOTIFY_DASH_BACK_PORT:?error} | ||
volumes: | ||
caddy_data: | ||
external: true | ||
caddy_config: |