Skip to content

Commit 14894f8

Browse files
authored
Alpine-Caddy (#7711)
1 parent b5f70e6 commit 14894f8

File tree

3 files changed

+129
-1
lines changed

3 files changed

+129
-1
lines changed

ct/alpine-caddy.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: cobalt (cobaltgit)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://caddyserver.com/
7+
8+
APP="Alpine-Caddy"
9+
var_tags="${var_tags:-webserver}"
10+
var_cpu="${var_cpu:-1}"
11+
var_ram="${var_ram:-256}"
12+
var_disk="${var_disk:-3}"
13+
var_os="${var_os:-alpine}"
14+
var_version="${var_version:-3.22}"
15+
var_unprivileged="${var_unprivileged:-1}"
16+
17+
header_info "$APP"
18+
variables
19+
color
20+
catch_errors
21+
22+
function update_script() {
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [[ ! -d /etc/caddy ]]; then
27+
msg_error "No ${APP} Installation Found!"
28+
exit
29+
fi
30+
msg_info "Updating $APP LXC"
31+
$STD apk -U upgrade
32+
msg_ok "Updated $APP LXC"
33+
34+
msg_info "Restarting Caddy"
35+
rc-service caddy restart
36+
msg_ok "Restarted Caddy"
37+
exit
38+
}
39+
40+
start
41+
build_container
42+
description
43+
44+
msg_ok "Completed Successfully!\n"
45+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
46+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
47+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:80${CL}"

frontend/public/json/caddy.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"categories": [
55
21
66
],
7-
"date_created": "2024-05-11",
7+
"date_created": "2025-09-17",
88
"type": "ct",
99
"updateable": true,
1010
"privileged": false,
@@ -25,6 +25,17 @@
2525
"os": "debian",
2626
"version": "12"
2727
}
28+
},
29+
{
30+
"type": "alpine",
31+
"script": "ct/alpine-caddy.sh",
32+
"resources": {
33+
"cpu": 1,
34+
"ram": 256,
35+
"hdd": 3,
36+
"os": "alpine",
37+
"version": "3.22"
38+
}
2839
}
2940
],
3041
"default_credentials": {

install/alpine-caddy-install.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: cobalt (cobaltgit)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://caddyserver.com/
7+
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Caddy"
17+
$STD apk add --no-cache caddy caddy-openrc
18+
cat <<EOF >/etc/caddy/Caddyfile
19+
:80 {
20+
# Set this path to your site's directory.
21+
root * /var/www/html
22+
23+
# Enable the static file server.
24+
file_server
25+
26+
# Another common task is to set up a reverse proxy:
27+
# reverse_proxy localhost:8080
28+
29+
# Or serve a PHP site through php-fpm:
30+
# php_fastcgi localhost:9000
31+
}
32+
EOF
33+
mkdir -p /var/www/html
34+
cat <<EOF >/var/www/html/index.html
35+
<!DOCTYPE html>
36+
<html>
37+
<head>
38+
<title>Caddy works!</title>
39+
</head>
40+
<body>
41+
<h1>Hello Caddy!</h1>
42+
<p>For more information, refer to the Caddy <a href="https://caddyserver.com/docs/">documentation</a><p>
43+
</body>
44+
</html>
45+
EOF
46+
msg_ok "Installed Caddy"
47+
48+
read -r -p "${TAB3}Would you like to install xCaddy Addon? <y/N> " prompt
49+
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
50+
GO_VERSION="$(curl -fsSL https://go.dev/VERSION?m=text | head -1 | cut -c3-)" setup_go
51+
msg_info "Setup xCaddy"
52+
cd /opt
53+
RELEASE=$(curl -fsSL https://api.github.com/repos/caddyserver/xcaddy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
54+
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"
55+
$STD tar xzf xcaddy_"${RELEASE:1}"_linux_amd64.tar.gz -C /usr/local/bin xcaddy
56+
rm -rf /opt/xcaddy*
57+
$STD xcaddy build
58+
msg_ok "Setup xCaddy"
59+
fi
60+
61+
msg_info "Enabling Caddy Service"
62+
$STD rc-update add caddy default
63+
msg_ok "Enabled Caddy Service"
64+
65+
msg_info "Starting Caddy"
66+
$STD service caddy start
67+
msg_ok "Started Caddy"
68+
69+
motd_ssh
70+
customize

0 commit comments

Comments
 (0)