feat(caddy): add configurable S3 addressing style

- Add S3_ADDRESSING_STYLE env var for S3-compatible endpoints
- Set addressing style and region via aws configure set
- Region now persists in aws config rather than process env var
This commit is contained in:
siujamo committed 2026-09-02 15:13:33 +08:00
1 parent 8931598794
commit ece2af988b
1 file changed
+6 -2
+6 -2
View File
@@ -17,6 +17,8 @@ S3_REGION="${S3_REGION:-us-east-1}"
S3_ACCESS_KEY="${S3_ACCESS_KEY:-}" S3_ACCESS_KEY="${S3_ACCESS_KEY:-}"
S3_SECRET_KEY="${S3_SECRET_KEY:-}" S3_SECRET_KEY="${S3_SECRET_KEY:-}"
BIN_URI="${BIN_URI:-caddy-custom-linux-amd64}" BIN_URI="${BIN_URI:-caddy-custom-linux-amd64}"
# S3 addressing style: 'virtual' (default), 'path', or 'auto'
S3_ADDRESSING_STYLE="${S3_ADDRESSING_STYLE:-virtual}"
BIN_SOURCE="./${BIN_URI}" BIN_SOURCE="./${BIN_URI}"
BIN_DEST="/usr/local/bin/caddy" BIN_DEST="/usr/local/bin/caddy"
@@ -34,10 +36,12 @@ if [ ! -f "${BIN_SOURCE}" ]; then
if [ -n "${S3_BUCKET}" ]; then if [ -n "${S3_BUCKET}" ]; then
echo "Local binary '${BIN_SOURCE}' not found. Downloading from S3 bucket '${S3_BUCKET}'..." echo "Local binary '${BIN_SOURCE}' not found. Downloading from S3 bucket '${S3_BUCKET}'..."
# Export AWS credentials for the current execution # Configure addressing style and region
aws configure set default.s3.addressing_style "${S3_ADDRESSING_STYLE}"
aws configure set default.region "${S3_REGION}"
export AWS_ACCESS_KEY_ID="${S3_ACCESS_KEY}" export AWS_ACCESS_KEY_ID="${S3_ACCESS_KEY}"
export AWS_SECRET_ACCESS_KEY="${S3_SECRET_KEY}" export AWS_SECRET_ACCESS_KEY="${S3_SECRET_KEY}"
export AWS_DEFAULT_REGION="${S3_REGION}"
AWS_CMD_ARGS=() AWS_CMD_ARGS=()
if [ -n "${S3_ENDPOINT}" ]; then if [ -n "${S3_ENDPOINT}" ]; then