Config traefik to serve the web from whispermoney.dev

This commit is contained in:
Víctor Falcón 2025-11-14 09:09:19 +01:00
parent 2c696aa88a
commit bb024d5e40
5 changed files with 92 additions and 2 deletions

1
.gitignore vendored
View File

@ -27,3 +27,4 @@ yarn-error.log
/.vscode
/.zed
.php-cs-fixer.cache
/traefik/certs/*.pem

View File

@ -1,8 +1,31 @@
services:
traefik:
image: 'traefik:v3.0'
command:
- '--api.insecure=true'
- '--providers.docker=true'
- '--providers.docker.exposedbydefault=false'
- '--providers.file.directory=/etc/traefik/dynamic'
- '--providers.file.watch=true'
- '--entrypoints.web.address=:80'
- '--entrypoints.websecure.address=:443'
- '--log.level=INFO'
ports:
- '80:80'
- '443:443'
- '8080:8080'
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:ro'
- './traefik/dynamic:/etc/traefik/dynamic:ro'
- './traefik/certs:/etc/traefik/certs:ro'
networks:
- sail
extra_hosts:
- 'host.docker.internal:host-gateway'
mysql:
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
- '${FORWARD_DB_PORT:-3307}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: '%'
@ -27,7 +50,7 @@ services:
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
- '${FORWARD_REDIS_PORT:-6380}:6379'
volumes:
- 'sail-redis:/data'
networks:

0
traefik/certs/.gitkeep Normal file
View File

View File

@ -0,0 +1,32 @@
http:
routers:
whispermoney-http:
rule: Host(`whispermoney.test`)
entryPoints:
- web
middlewares:
- redirect-to-https
service: whispermoney
whispermoney-https:
rule: Host(`whispermoney.test`)
entryPoints:
- websecure
service: whispermoney
tls: {}
middlewares:
redirect-to-https:
redirectScheme:
scheme: https
permanent: true
services:
whispermoney:
loadBalancer:
servers:
- url: http://host.docker.internal:8000
tls:
certificates:
- certFile: /etc/traefik/certs/whispermoney.test.pem
keyFile: /etc/traefik/certs/whispermoney.test-key.pem

34
traefik/generate-certs.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
set -e
if ! command -v mkcert &> /dev/null; then
echo "mkcert is not installed. Installing..."
if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &> /dev/null; then
brew install mkcert
brew install nss
else
echo "Please install Homebrew first, then run: brew install mkcert nss"
exit 1
fi
else
echo "Please install mkcert manually. Visit: https://github.com/FiloSottile/mkcert"
exit 1
fi
fi
if [ ! -f "$(mkcert -CAROOT)/rootCA.pem" ]; then
echo "Installing local CA..."
mkcert -install
fi
echo "Generating certificates for whispermoney.test..."
cd "$(dirname "$0")/certs"
mkcert -key-file whispermoney.test-key.pem -cert-file whispermoney.test.pem whispermoney.test
echo "Certificates generated successfully!"
echo "Files created:"
echo " - traefik/certs/whispermoney.test.pem"
echo " - traefik/certs/whispermoney.test-key.pem"