Fix HTTPS configuration: use service hostname for networking and add HTTP-only compose file

- Updated service name from 'digiserver' to 'digiserver-app' in docker-compose.yml for proper Docker network DNS resolution
- Fixed Caddyfile to reference correct service hostname 'digiserver-app:5000'
- Changed port mapping from 'ports' to 'expose' for internal-only access
- Added docker-compose.http.yml for HTTP-only deployment on port 80 (development/testing)
- Both Flask app and Caddy now communicate correctly over internal Docker network
- App now accessible at https://localhost or https://your-domain.com on port 443
This commit is contained in:
Quality App Developer
2026-01-13 15:20:25 +02:00
parent fc4c8a7474
commit ef17abfe6b
3 changed files with 34 additions and 6 deletions

4
Caddyfile Normal file → Executable file
View File

@@ -9,7 +9,7 @@
# Automatic HTTPS (Caddy handles Let's Encrypt automatically)
# Reverse proxy to Flask app
reverse_proxy digiserver:5000 {
reverse_proxy digiserver-app:5000 {
header_up Host {host}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
@@ -44,7 +44,7 @@
# Handle IP address access without automatic HTTPS
http://192.168.0.206 {
# Reverse proxy to Flask app
reverse_proxy digiserver:5000 {
reverse_proxy digiserver-app:5000 {
# Headers
header_up Host {host}
header_up X-Real-IP {remote_host}

27
docker-compose.http.yml Normal file
View File

@@ -0,0 +1,27 @@
version: '3.8'
services:
digiserver:
build: .
container_name: digiserver-v2-http
ports:
- "80:5000" # Direct HTTP exposure on port 80
volumes:
- ./instance:/app/instance
- ./app/static/uploads:/app/app/static/uploads
environment:
- FLASK_ENV=production
- SECRET_KEY=${SECRET_KEY:-your-secret-key-change-this}
- ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
- ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin123}
restart: unless-stopped
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:5000/').read()"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Usage: docker-compose -f docker-compose.http.yml up -d
# Access at: http://localhost or http://your-server-ip
# Note: This is for development/testing only. Use docker-compose.yml for production HTTPS.

9
docker-compose.yml Normal file → Executable file
View File

@@ -1,12 +1,12 @@
#version: '3.8'
services:
digiserver:
digiserver-app:
build: .
container_name: digiserver-v2
# Don't expose directly; use Caddy reverse proxy instead
ports:
- "5000" # Internal only, accessed via Caddy
expose:
- "5000"
volumes:
- ./instance:/app/instance
- ./app/static/uploads:/app/app/static/uploads
@@ -41,7 +41,8 @@ services:
- DOMAIN=${DOMAIN:-localhost}
- EMAIL=${EMAIL:-admin@localhost}
depends_on:
- digiserver
digiserver-app:
condition: service_started
restart: unless-stopped
networks:
- digiserver-network