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:
4
Caddyfile
Normal file → Executable file
4
Caddyfile
Normal file → Executable file
@@ -9,7 +9,7 @@
|
|||||||
# Automatic HTTPS (Caddy handles Let's Encrypt automatically)
|
# Automatic HTTPS (Caddy handles Let's Encrypt automatically)
|
||||||
|
|
||||||
# Reverse proxy to Flask app
|
# Reverse proxy to Flask app
|
||||||
reverse_proxy digiserver:5000 {
|
reverse_proxy digiserver-app:5000 {
|
||||||
header_up Host {host}
|
header_up Host {host}
|
||||||
header_up X-Real-IP {remote_host}
|
header_up X-Real-IP {remote_host}
|
||||||
header_up X-Forwarded-For {remote_host}
|
header_up X-Forwarded-For {remote_host}
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
# Handle IP address access without automatic HTTPS
|
# Handle IP address access without automatic HTTPS
|
||||||
http://192.168.0.206 {
|
http://192.168.0.206 {
|
||||||
# Reverse proxy to Flask app
|
# Reverse proxy to Flask app
|
||||||
reverse_proxy digiserver:5000 {
|
reverse_proxy digiserver-app:5000 {
|
||||||
# Headers
|
# Headers
|
||||||
header_up Host {host}
|
header_up Host {host}
|
||||||
header_up X-Real-IP {remote_host}
|
header_up X-Real-IP {remote_host}
|
||||||
|
|||||||
27
docker-compose.http.yml
Normal file
27
docker-compose.http.yml
Normal 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
9
docker-compose.yml
Normal file → Executable file
@@ -1,12 +1,12 @@
|
|||||||
#version: '3.8'
|
#version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
digiserver:
|
digiserver-app:
|
||||||
build: .
|
build: .
|
||||||
container_name: digiserver-v2
|
container_name: digiserver-v2
|
||||||
# Don't expose directly; use Caddy reverse proxy instead
|
# Don't expose directly; use Caddy reverse proxy instead
|
||||||
ports:
|
expose:
|
||||||
- "5000" # Internal only, accessed via Caddy
|
- "5000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./instance:/app/instance
|
- ./instance:/app/instance
|
||||||
- ./app/static/uploads:/app/app/static/uploads
|
- ./app/static/uploads:/app/app/static/uploads
|
||||||
@@ -41,7 +41,8 @@ services:
|
|||||||
- DOMAIN=${DOMAIN:-localhost}
|
- DOMAIN=${DOMAIN:-localhost}
|
||||||
- EMAIL=${EMAIL:-admin@localhost}
|
- EMAIL=${EMAIL:-admin@localhost}
|
||||||
depends_on:
|
depends_on:
|
||||||
- digiserver
|
digiserver-app:
|
||||||
|
condition: service_started
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- digiserver-network
|
- digiserver-network
|
||||||
|
|||||||
Reference in New Issue
Block a user