diff --git a/docker/production/Caddyfile b/docker/production/Caddyfile index 0a98ab7..1fec201 100644 --- a/docker/production/Caddyfile +++ b/docker/production/Caddyfile @@ -1,9 +1,18 @@ { skip_install_trust - http_port 8080 - https_port 443 + http_port {$HTTP_PORT} + https_port {$HTTPS_PORT} } -:443 { + +:{$HTTP_PORT} { + redir / /web + uri strip_prefix /web + file_server { + root /web + } +} + +:{$HTTPS_PORT} { redir / /web uri strip_prefix /web tls internal { diff --git a/docker/production/dockerfile b/docker/production/dockerfile index f184ab6..1147635 100644 --- a/docker/production/dockerfile +++ b/docker/production/dockerfile @@ -34,8 +34,9 @@ FROM alpine:latest ENV PROJECT_NAME="headscale-ui" # URL for the github/git location ENV PROJECT_URL="https://github.com/gurucomputing/headscale-ui" -# Port that caddy will run on -ENV PORT="443" +# Ports that caddy will run on +ENV HTTPS_PORT="443" +ENV HTTP_PORT="80" # Production Web Server port. Runs a self signed SSL certificate EXPOSE 443 diff --git a/docker/production/scripts/2-initialise.sh b/docker/production/scripts/2-initialise.sh index 13f141f..029a5f1 100644 --- a/docker/production/scripts/2-initialise.sh +++ b/docker/production/scripts/2-initialise.sh @@ -12,11 +12,5 @@ then cp /staging/Caddyfile /data/Caddyfile fi -# replace port in Caddyfile if set -if [ "$PORT" != "443" ] -then - sed -i "s/443/$PORT/g" /data/Caddyfile -fi - echo "Starting Caddy" /usr/sbin/caddy run --adapter caddyfile --config /data/Caddyfile