Skip to content

Commit

Permalink
Merge pull request #19 from szaimen/enh/16/trust-aio-gateway
Browse files Browse the repository at this point in the history
trust the nextcloud-aio gateway
  • Loading branch information
szaimen authored Jan 13, 2024
2 parents 04916ff + 88e1906 commit 3021a25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
root /data/caddy
}

servers {
trusted_proxies placeholder
}

log {
level ERROR
}
Expand Down
7 changes: 7 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ while ! [ -f /nextcloud/admin/files/nextcloud-aio-caddy/allowed-countries.txt ];
sleep 5
done

# Get ipv4-address of caddy
IPv4_ADDRESS="$(dig nextcloud-aio-caddy A +short +search | head -1)"
# Bring it in CIDR notation
# shellcheck disable=SC2001
IPv4_ADDRESS="$(echo "$IPv4_ADDRESS" | sed 's|[0-9]\+$|1/32|')"
sed -i "s|trusted_proxies.*|trusted_proxies static $IPv4_ADDRESS|" /Caddyfile

ALLOW_CONTRIES="$(head -n 1 /nextcloud/admin/files/nextcloud-aio-caddy/allowed-countries.txt)"
if echo "$ALLOW_CONTRIES" | grep -q '^[A-Z ]\+$'; then
FILTER_SET=1
Expand Down

0 comments on commit 3021a25

Please sign in to comment.