From a7814274514e5621d3280c937d8976768504f12c Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Mon, 15 Sep 2025 13:05:14 +0100 Subject: [PATCH 01/10] ct: add Alpine Linux Caddy --- ct/alpine-caddy.sh | 47 ++++++++++++++++++++ ct/headers/alpine-caddy | 6 +++ frontend/public/json/alpine-caddy.json | 59 ++++++++++++++++++++++++++ install/alpine-caddy-install.sh | 43 +++++++++++++++++++ 4 files changed, 155 insertions(+) create mode 100644 ct/alpine-caddy.sh create mode 100644 ct/headers/alpine-caddy create mode 100644 frontend/public/json/alpine-caddy.json create mode 100644 install/alpine-caddy-install.sh diff --git a/ct/alpine-caddy.sh b/ct/alpine-caddy.sh new file mode 100644 index 000000000..55c73eab6 --- /dev/null +++ b/ct/alpine-caddy.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 cobalt +# Author: cobalt (cobaltgit) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://caddyserver.com/ + +APP="Alpine-Caddy" +var_tags="${var_tags:-webserver}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-256}" +var_disk="${var_disk:-3}" +var_os="${var_os:-alpine}" +var_version="${var_version:-3.22}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -d /etc/caddy ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_info "Updating $APP LXC" + $STD apk -U upgrade + msg_ok "Updated $APP LXC" + + msg_info "Restarting Caddy" + rc-service caddy restart + msg_ok "Restarted Caddy" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:80${CL}" diff --git a/ct/headers/alpine-caddy b/ct/headers/alpine-caddy new file mode 100644 index 000000000..75208a457 --- /dev/null +++ b/ct/headers/alpine-caddy @@ -0,0 +1,6 @@ + ___ __ _ ______ __ __ + / | / /___ (_)___ ___ / ____/___ _____/ /___/ /_ __ + / /| | / / __ \/ / __ \/ _ \______/ / / __ `/ __ / __ / / / / + / ___ |/ / /_/ / / / / / __/_____/ /___/ /_/ / /_/ / /_/ / /_/ / +/_/ |_/_/ .___/_/_/ /_/\___/ \____/\__,_/\__,_/\__,_/\__, / + /_/ /____/ diff --git a/frontend/public/json/alpine-caddy.json b/frontend/public/json/alpine-caddy.json new file mode 100644 index 000000000..1ce595ade --- /dev/null +++ b/frontend/public/json/alpine-caddy.json @@ -0,0 +1,59 @@ +{ + "name": "Caddy", + "slug": "caddy", + "categories": [ + 21 + ], + "date_created": "2024-05-11", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 80, + "documentation": "https://caddyserver.com/docs/", + "website": "https://caddyserver.com/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/caddy.webp", + "config_path": "/etc/caddy/Caddyfile", + "description": "Caddy is a powerful, extensible platform to serve your sites, services, and apps, written in Go.", + "install_methods": [ + { + "type": "default", + "script": "ct/caddy.sh", + "resources": { + "cpu": 1, + "ram": 512, + "hdd": 4, + "os": "debian", + "version": "12" + }, + { + "type": "alpine", + "script": "ct/alpine-caddy.sh", + "resources": { + "cpu": 1, + "ram": 256, + "hdd": 3, + "os": "alpine", + "version": "3.22" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "xcaddy needs to be updated manually after a caddy update!", + "type": "warning" + }, + { + "text": "if you need an internal module run: `caddy add-package PACKAGENAME`", + "type": "info" + }, + { + "text": "if you need an external module run: `xcaddy build --with github.com/caddy-dns/cloudflare`", + "type": "info" + } + ] +} + diff --git a/install/alpine-caddy-install.sh b/install/alpine-caddy-install.sh new file mode 100644 index 000000000..8f2541505 --- /dev/null +++ b/install/alpine-caddy-install.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 cobalt +# Author: cobalt (cobaltgit) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://caddyserver.com/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Caddy" +$STD apk add --no-cache caddy caddy-openrc +msg_ok "Installed Caddy" + +read -r -p "${TAB3}Would you like to install xCaddy Addon? " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + setup_go + msg_info "Setup xCaddy" + $STD apk add --no-cache git + cd /opt + RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz" + $STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin + rm -rf /opt/xcaddy* + $STD xcaddy build + msg_ok "Setup xCaddy" +fi + +msg_info "Enabling Caddy Service" +$STD rc-update add caddy default +msg_ok "Enabled Caddy Service" + +msg_info "Starting Caddy" +$STD service caddy start +msg_ok "Started Caddy" + +motd_ssh +customize From e5819be4ec2807c27c266bb59c926cf19e7c7474 Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Mon, 15 Sep 2025 13:07:14 +0100 Subject: [PATCH 02/10] frontend: fix alpine caddy json --- frontend/public/json/alpine-caddy.json | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/frontend/public/json/alpine-caddy.json b/frontend/public/json/alpine-caddy.json index 1ce595ade..e8d8c5feb 100644 --- a/frontend/public/json/alpine-caddy.json +++ b/frontend/public/json/alpine-caddy.json @@ -15,15 +15,16 @@ "config_path": "/etc/caddy/Caddyfile", "description": "Caddy is a powerful, extensible platform to serve your sites, services, and apps, written in Go.", "install_methods": [ - { - "type": "default", - "script": "ct/caddy.sh", - "resources": { - "cpu": 1, - "ram": 512, - "hdd": 4, - "os": "debian", - "version": "12" + { + "type": "default", + "script": "ct/caddy.sh", + "resources": { + "cpu": 1, + "ram": 512, + "hdd": 4, + "os": "debian", + "version": "12" + } }, { "type": "alpine", From cfe24835d90ce557e1b8f72f6a376054f3840dfd Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Mon, 15 Sep 2025 13:11:55 +0100 Subject: [PATCH 03/10] ct: alpine caddy: source development build.func --- ct/alpine-caddy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/alpine-caddy.sh b/ct/alpine-caddy.sh index 55c73eab6..1b629fa90 100644 --- a/ct/alpine-caddy.sh +++ b/ct/alpine-caddy.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2025 cobalt # Author: cobalt (cobaltgit) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE From 383502f5e296f0d4b1032f95c655ad58c56a40c5 Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Mon, 15 Sep 2025 13:24:48 +0100 Subject: [PATCH 04/10] alpine-caddy: change copyright to community-scripts ORG --- ct/alpine-caddy.sh | 2 +- install/alpine-caddy-install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ct/alpine-caddy.sh b/ct/alpine-caddy.sh index 1b629fa90..29e61b2ef 100644 --- a/ct/alpine-caddy.sh +++ b/ct/alpine-caddy.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) -# Copyright (c) 2021-2025 cobalt +# Copyright (c) 2021-2025 community-scripts ORG # Author: cobalt (cobaltgit) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://caddyserver.com/ diff --git a/install/alpine-caddy-install.sh b/install/alpine-caddy-install.sh index 8f2541505..929a7d592 100644 --- a/install/alpine-caddy-install.sh +++ b/install/alpine-caddy-install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2021-2025 cobalt +# Copyright (c) 2021-2025 community-scripts ORG # Author: cobalt (cobaltgit) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://caddyserver.com/ From bd1dbc64b1de552a145879825fb5b257533202a5 Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Mon, 15 Sep 2025 13:34:12 +0100 Subject: [PATCH 05/10] alpine-caddy: use apk for xcaddy --- install/alpine-caddy-install.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/install/alpine-caddy-install.sh b/install/alpine-caddy-install.sh index 929a7d592..5774087c8 100644 --- a/install/alpine-caddy-install.sh +++ b/install/alpine-caddy-install.sh @@ -19,14 +19,8 @@ msg_ok "Installed Caddy" read -r -p "${TAB3}Would you like to install xCaddy Addon? " prompt if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - setup_go msg_info "Setup xCaddy" - $STD apk add --no-cache git - cd /opt - RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz" - $STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin - rm -rf /opt/xcaddy* + $STD apk add --no-cache xcaddy $STD xcaddy build msg_ok "Setup xCaddy" fi From 2510dd7da031910fad5b530ec2dba2fe8e2f1661 Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Mon, 15 Sep 2025 17:56:32 +0100 Subject: [PATCH 06/10] alpine-caddy: revert to manually setting up go and xcaddy Alpine repos currently have an outdated version of Golang, latest version of caddy refuses to build with xcaddy --- install/alpine-caddy-install.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/install/alpine-caddy-install.sh b/install/alpine-caddy-install.sh index 5774087c8..c3bd7cf49 100644 --- a/install/alpine-caddy-install.sh +++ b/install/alpine-caddy-install.sh @@ -19,8 +19,13 @@ msg_ok "Installed Caddy" read -r -p "${TAB3}Would you like to install xCaddy Addon? " prompt if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go msg_info "Setup xCaddy" - $STD apk add --no-cache xcaddy + cd /opt + RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz" + $STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin + rm -rf /opt/xcaddy* $STD xcaddy build msg_ok "Setup xCaddy" fi From ef69b4d0a72b2570ffcfa4ec6b926b93c927def2 Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Mon, 15 Sep 2025 18:04:28 +0100 Subject: [PATCH 07/10] alpine-caddy: only extract xcaddy binary from release tarball --- install/alpine-caddy-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/alpine-caddy-install.sh b/install/alpine-caddy-install.sh index c3bd7cf49..9e798acca 100644 --- a/install/alpine-caddy-install.sh +++ b/install/alpine-caddy-install.sh @@ -6,7 +6,7 @@ # Source: https://caddyserver.com/ source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" -color +colorYea verb_ip6 catch_errors setting_up_container @@ -24,7 +24,7 @@ if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then cd /opt RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz" - $STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin + $STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin xcaddy rm -rf /opt/xcaddy* $STD xcaddy build msg_ok "Setup xCaddy" From cadd02ed4b1ee6db73a2a361b5e4999d5a1619a1 Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Mon, 15 Sep 2025 18:05:16 +0100 Subject: [PATCH 08/10] alpine-caddy: fix typo! ok i guess we should implement colorYea :kekw: --- install/alpine-caddy-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/alpine-caddy-install.sh b/install/alpine-caddy-install.sh index 9e798acca..6873dced1 100644 --- a/install/alpine-caddy-install.sh +++ b/install/alpine-caddy-install.sh @@ -6,7 +6,7 @@ # Source: https://caddyserver.com/ source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" -colorYea +color verb_ip6 catch_errors setting_up_container From 7e5cbc40726036756787dd883f5f012eff859790 Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Wed, 17 Sep 2025 10:17:55 +0100 Subject: [PATCH 09/10] alpine-caddy: add default Caddyfile and webpage --- install/alpine-caddy-install.sh | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/install/alpine-caddy-install.sh b/install/alpine-caddy-install.sh index 6873dced1..f1b59d425 100644 --- a/install/alpine-caddy-install.sh +++ b/install/alpine-caddy-install.sh @@ -30,6 +30,47 @@ if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then msg_ok "Setup xCaddy" fi +cat</etc/caddy/Caddyfile +# The Caddyfile is an easy way to configure your Caddy web server. +# +# Unless the file starts with a global options block, the first +# uncommented line is always the address of your site. +# +# To use your own domain name (with automatic HTTPS), first make +# sure your domain's A/AAAA DNS records are properly pointed to +# this machine's public IP, then replace ":80" below with your +# domain name. + +:80 { + # Set this path to your site's directory. + root * /var/www/html + + # Enable the static file server. + file_server + + # Another common task is to set up a reverse proxy: + # reverse_proxy localhost:8080 + + # Or serve a PHP site through php-fpm: + # php_fastcgi localhost:9000 +} + +# Refer to the Caddy docs for more information: +# https://caddyserver.com/docs/caddyfile +EOF +mkdir -p /var/www/html +cat</var/www/html/index.html + + + + Caddy works! + + +

Hello Caddy!

+

For more information, refer to the Caddy documentation

+ + +EOF msg_info "Enabling Caddy Service" $STD rc-update add caddy default msg_ok "Enabled Caddy Service" From 3fd2f00a913eff6669b1f18723febeaf5ad7badf Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Wed, 17 Sep 2025 10:18:33 +0100 Subject: [PATCH 10/10] alpine-caddy: move config creation to install step --- install/alpine-caddy-install.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/install/alpine-caddy-install.sh b/install/alpine-caddy-install.sh index f1b59d425..d34d9a3cc 100644 --- a/install/alpine-caddy-install.sh +++ b/install/alpine-caddy-install.sh @@ -15,21 +15,6 @@ update_os msg_info "Installing Caddy" $STD apk add --no-cache caddy caddy-openrc -msg_ok "Installed Caddy" - -read -r -p "${TAB3}Would you like to install xCaddy Addon? " prompt -if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go - msg_info "Setup xCaddy" - cd /opt - RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz" - $STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin xcaddy - rm -rf /opt/xcaddy* - $STD xcaddy build - msg_ok "Setup xCaddy" -fi - cat</etc/caddy/Caddyfile # The Caddyfile is an easy way to configure your Caddy web server. # @@ -71,6 +56,21 @@ cat</var/www/html/index.html EOF +msg_ok "Installed Caddy" + +read -r -p "${TAB3}Would you like to install xCaddy Addon? " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go + msg_info "Setup xCaddy" + cd /opt + RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + curl -fsSL "https://github.com/caddyserver/xcaddy/releases/download/${RELEASE}/xcaddy_${RELEASE:1}_linux_amd64.tar.gz" -o "xcaddy_${RELEASE:1}_linux_amd64.tar.gz" + $STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin xcaddy + rm -rf /opt/xcaddy* + $STD xcaddy build + msg_ok "Setup xCaddy" +fi + msg_info "Enabling Caddy Service" $STD rc-update add caddy default msg_ok "Enabled Caddy Service"