on master help sign in
Require DOMAIN in install script, add Caddy reverse proxy with automatic TLS, add servers.json
ac03169iko
README.md+2−2
@@ -5,7 +5,7 @@ Decentralized, end-to-end encrypted messaging with no accounts and no home serve
5## Install the relay server
5## Install the relay server
6
6
7```sh
7```sh
8−curl -fsSL https://raw.githubusercontent.com/ilyakooo0/skrepka/master/install.sh | sudo sh
8+curl -fsSL https://raw.githubusercontent.com/ilyakooo0/skrepka/master/install.sh | sudo DOMAIN=skrepka.example.com sh
9```
9```
10
10
11−This downloads the latest binary for your platform, installs it to `/usr/local/bin/skrepka-server`, and on Linux sets up a systemd service. Re-running the same command will update the binary and restart the service.
11+This installs the server binary, sets up a systemd service, and configures [Caddy](https://caddyserver.com) as a reverse proxy with automatic TLS. Re-running the same command will update the binary and restart the service.
install.sh+33−4
@@ -5,6 +5,14 @@ REPO="ilyakooo0/skrepka"
5INSTALL_BIN="/usr/local/bin/skrepka-server"
5INSTALL_BIN="/usr/local/bin/skrepka-server"
6UNIT_DEST="/etc/systemd/system/skrepka.service"
6UNIT_DEST="/etc/systemd/system/skrepka.service"
7
7
8+DOMAIN="${DOMAIN:-${1:-}}"
9+
10+if [ -z "$DOMAIN" ]; then
11+ echo "error: DOMAIN is required" >&2
12+ echo "usage: DOMAIN=skrepka.example.com sh install.sh" >&2
13+ exit 1
14+fi
15+
8if [ "$(id -u)" -ne 0 ]; then
16if [ "$(id -u)" -ne 0 ]; then
9 echo "error: must be run as root" >&2
17 echo "error: must be run as root" >&2
10 exit 1
18 exit 1
@@ -76,12 +84,30 @@ NoNewPrivileges=yes
76WantedBy=multi-user.target
84WantedBy=multi-user.target
77EOF
85EOF
78
86
87+ if ! command -v caddy >/dev/null 2>&1; then
88+ echo "Installing Caddy..."
89+ apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl
90+ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
91+ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
92+ apt-get update
93+ apt-get install -y caddy
94+ fi
95+
96+ mkdir -p /etc/caddy
97+ cat > /etc/caddy/Caddyfile <<CADDYEOF
98+${DOMAIN} {
99+ reverse_proxy localhost:8080
100+}
101+CADDYEOF
102+
79 if command -v ufw >/dev/null 2>&1 && ufw status | grep -q "active"; then
103 if command -v ufw >/dev/null 2>&1 && ufw status | grep -q "active"; then
80− echo "Opening port 8080 (ufw)..."
104+ echo "Opening ports 80, 443 (ufw)..."
81− ufw allow 8080/tcp
105+ ufw allow 80/tcp
106+ ufw allow 443/tcp
82 elif command -v firewall-cmd >/dev/null 2>&1 && systemctl is-active --quiet firewalld; then
107 elif command -v firewall-cmd >/dev/null 2>&1 && systemctl is-active --quiet firewalld; then
83− echo "Opening port 8080 (firewalld)..."
108+ echo "Opening ports 80, 443 (firewalld)..."
84− firewall-cmd --add-port=8080/tcp --permanent
109+ firewall-cmd --add-port=80/tcp --permanent
110+ firewall-cmd --add-port=443/tcp --permanent
85 firewall-cmd --reload
111 firewall-cmd --reload
86 fi
112 fi
87
113
@@ -94,6 +120,9 @@ EOF
94 systemctl enable --now skrepka
120 systemctl enable --now skrepka
95 echo "Service enabled and started."
121 echo "Service enabled and started."
96 fi
122 fi
123+
124+ systemctl restart caddy
125+ echo "Caddy configured for https://${DOMAIN}"
97 echo "Check status with: systemctl status skrepka"
126 echo "Check status with: systemctl status skrepka"
98 ;;
127 ;;
99 *)
128 *)
servers.jsonnew file+5
@@ -0,0 +1,5 @@
1+[
2+ "https://178.72.170.73",
3+ "https://45.66.117.187",
4+ "https://158.160.236.107"
5+]