diff --git a/config/zoraxy/conf/proxy/app.nextwks.eu.config b/config/zoraxy/conf/proxy/app.nextwks.eu.config index 57f99fc..2c311e3 100644 --- a/config/zoraxy/conf/proxy/app.nextwks.eu.config +++ b/config/zoraxy/conf/proxy/app.nextwks.eu.config @@ -1,16 +1,49 @@ { - "ProxyType": 1, - "RootOrMatchingDomain": "app.nextwks.eu", - "ActiveOrigins": [ - { - "OriginIpOrDomain": "127.0.0.1:9000", - "RequireTLS": false, - "Weight": 1, - "MaxConn": 0 - } - ], - "Disabled": false, - "AuthenticationProvider": { - "AuthMethod": 4 - } + "ProxyType": 1, + "RootOrMatchingDomain": "app.nextwks.eu", + "MatchingDomainAlias": [], + "ActiveOrigins": [ + { + "OriginIpOrDomain": "127.0.0.1:9000", + "RequireTLS": false, + "SkipCertValidations": false, + "SkipWebSocketOriginCheck": false, + "Weight": 1, + "MaxConn": 0, + "RespTimeout": 0 + } + ], + "InactiveOrigins": [], + "UseStickySession": false, + "UseActiveLoadBalance": false, + "Disabled": false, + "BypassGlobalTLS": false, + "VirtualDirectories": [], + "HeaderRewriteRules": { + "UserDefinedHeaders": null, + "RequestHostOverwrite": "", + "HSTSMaxAge": 0, + "EnablePermissionPolicyHeader": false, + "PermissionPolicy": null, + "DisableHopByHopHeaderRemoval": false + }, + "EnableWebsocketCustomHeaders": false, + "AuthenticationProvider": { + "AuthMethod": 4, + "BasicAuthCredentials": null, + "BasicAuthExceptionRules": null, + "BasicAuthGroupIDs": [], + "ForwardAuthURL": "", + "ForwardAuthResponseHeaders": [], + "ForwardAuthResponseClientHeaders": [], + "ForwardAuthRequestHeaders": [], + "ForwardAuthRequestExcludedCookies": [] + }, + "RequireRateLimit": false, + "RateLimit": 0, + "DisableUptimeMonitor": false, + "AccessFilterUUID": "", + "DefaultSiteOption": 0, + "DefaultSiteValue": "", + "Tags": [] } diff --git a/config/zoraxy/conf/proxy/dns.nextwks.eu.config b/config/zoraxy/conf/proxy/dns.nextwks.eu.config new file mode 100644 index 0000000..d8498aa --- /dev/null +++ b/config/zoraxy/conf/proxy/dns.nextwks.eu.config @@ -0,0 +1,17 @@ +{ + "ProxyType": 1, + "RootOrMatchingDomain": "dns.nextwks.eu", + "ActiveOrigins": [ + { + "OriginIpOrDomain": "127.0.0.1:8000", + "RequireTLS": false, + "Weight": 1, + "MaxConn": 0 + } + ], + "Disabled": false, + "AuthenticationProvider": { + "AuthMethod": 4 + }, + "BypassGlobalTLS": false +} diff --git a/config/zoraxy/conf/proxy/root.config b/config/zoraxy/conf/proxy/root.config index 5f058f7..4cd6b22 100644 --- a/config/zoraxy/conf/proxy/root.config +++ b/config/zoraxy/conf/proxy/root.config @@ -1,9 +1,39 @@ { - "ProxyType": 1, - "RootOrMatchingDomain": "*", - "ActiveOrigins": [], - "Disabled": false, - "AuthenticationProvider": { - "AuthMethod": 0 - } + "ProxyType": 1, + "RootOrMatchingDomain": "*", + "MatchingDomainAlias": [], + "ActiveOrigins": [], + "InactiveOrigins": [], + "UseStickySession": false, + "UseActiveLoadBalance": false, + "Disabled": false, + "BypassGlobalTLS": false, + "VirtualDirectories": [], + "HeaderRewriteRules": { + "UserDefinedHeaders": null, + "RequestHostOverwrite": "", + "HSTSMaxAge": 0, + "EnablePermissionPolicyHeader": false, + "PermissionPolicy": null, + "DisableHopByHopHeaderRemoval": false + }, + "EnableWebsocketCustomHeaders": false, + "AuthenticationProvider": { + "AuthMethod": 0, + "BasicAuthCredentials": null, + "BasicAuthExceptionRules": null, + "BasicAuthGroupIDs": [], + "ForwardAuthURL": "", + "ForwardAuthResponseHeaders": [], + "ForwardAuthResponseClientHeaders": [], + "ForwardAuthRequestHeaders": [], + "ForwardAuthRequestExcludedCookies": [] + }, + "RequireRateLimit": false, + "RateLimit": 0, + "DisableUptimeMonitor": false, + "AccessFilterUUID": "", + "DefaultSiteOption": 0, + "DefaultSiteValue": "", + "Tags": [] } diff --git a/deploy.sh b/deploy.sh index 9302ae3..5f31bb9 100755 --- a/deploy.sh +++ b/deploy.sh @@ -8,6 +8,17 @@ BINARY_NAME="nextworkspace" HEALTH_CHECK_RETRIES=10 HEALTH_CHECK_INTERVAL=2 +# --- Load .env from runtime root --- +ENV_FILE="$TARGET_DIR/.env" +if [ -f "$ENV_FILE" ]; then + set -a + source "$ENV_FILE" + set +a +fi + +# Default domain if .env wasn't loaded +DOMAIN="${DOMAIN:-nextwks.eu}" + # --- Mode detection --- GREENFIELD=false if [ "${1:-}" = "--destroy" ]; then @@ -39,21 +50,87 @@ if [ "$GREENFIELD" = true ]; then mkdir -p "$TARGET_DIR/config/zoraxy/conf/proxy" mkdir -p "$TARGET_DIR/data/zoraxy" mkdir -p "$TARGET_DIR/compose" - mkdir -p "$TARGET_DIR/logs/zoraxy" + mkdir -p "$TARGET_DIR/logs" echo "[5/8] Copying binary..." cp "$BINARY_NAME" "$TARGET_DIR/$BINARY_NAME" - echo "[6/8] Copying config files..." - cp -r config/nextworkspace/* "$TARGET_DIR/config/nextworkspace/" - cp -r config/zoraxy/* "$TARGET_DIR/config/zoraxy/" + echo "[6/8] Deploying Zoraxy..." cp compose/zoraxy.yaml "$TARGET_DIR/compose/zoraxy.yaml" - - echo "[7/8] Deploying Zoraxy..." podman-compose -f "$TARGET_DIR/compose/zoraxy.yaml" up -d 2>&1 || echo "[WARN] Zoraxy deploy had issues (see above)" - echo "[8/8] Writing systemd service and starting launcher..." - mkdir -p "$TARGET_DIR" + # Generate Zoraxy proxy configs with actual domain + echo "[*] Generating Zoraxy proxy configs..." + cat > "$TARGET_DIR/config/zoraxy/conf/proxy/app.$DOMAIN.config" < "$TARGET_DIR/config/zoraxy/conf/proxy/dns.$DOMAIN.config" < /dev/null 2>&1; then + break + fi + echo " Waiting for Zoraxy... ($i/15)" + sleep 2 + done + + # Fetch CSRF token from Zoraxy login page + CSRF_TOKEN=$(curl -s http://127.0.0.1:8000/ | grep -oP '(?<=&1) + else + ADMIN_CREATE=$(curl -s -X POST "$ZORAXY_ADMIN_URL" \ + -H "X-CSRF-Token: $CSRF_TOKEN" \ + -d "username=${ADMIN_USERNAME:-admin}" \ + -d "password=${ADMIN_PASSWORD:-admin}" 2>&1) + fi + + if echo "$ADMIN_CREATE" | grep -qi '"success"\|"ok"\|"User registered\|"registered'; then + echo "[OK] Zoraxy admin account created" + elif echo "$ADMIN_CREATE" | grep -qi '"error"'; then + echo "[WARN] Admin account may already exist: $ADMIN_CREATE" + else + echo "[INFO] Admin API response: $ADMIN_CREATE" + fi + + # Write systemd service and start launcher + echo "[7/8] Writing systemd service and starting launcher..." cat > /etc/systemd/system/$SERVICE_NAME.service < "$ENV_FILE" </dev/null; then @@ -23,9 +67,9 @@ else fi # ---- System deps ---- -echo "[INSTALL] git, build-essential, podman..." +echo "[INSTALL] git, build-essential, podman, podman-compose..." apt-get update -qq -apt-get install -y -qq git build-essential curl podman +apt-get install -y -qq git build-essential curl podman podman-compose # ---- Clone / pull repo ---- REPO_DIR="/opt/NextWks"