Sign inSign up

wisicn/docker-caddy-s3

By wisicn

•Updated 6 months ago

Caddy file server that serves files from S3-compatible object storage using the caddy-fs-s3

Image
Web servers
0

1.6K

wisicn/docker-caddy-s3 repository overview

⁠Caddy S3 File Server

A Dockerized Caddy⁠ file server that serves files from S3-compatible object storage using the caddy-fs-s3⁠ module.

See the github repository https://github.com/wisicn/docker-caddy-s3⁠

⁠Features

  • 🚀 Lightweight Alpine-based Docker image
  • 📦 Serves files directly from S3-compatible storage (AWS S3, Tencent COS, MinIO, etc.)
  • 🔧 Easy configuration via environment variables
  • 📁 Built-in directory browsing
  • 🔄 Auto-restart on failure
  • 🔒 Runs as non-root user

⁠Quick Start

⁠1. Clone the Repository
git clone https://github.com/yourusername/docker-caddy-s3.git
cd docker-caddy-s3
⁠2. Configure Environment Variables

Create a .env file based on the example:

cp .env.example .env

Edit .env with your credentials:

# AWS/S3 Credentials
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key

# Web Server Port (default: 18808)
WEB_PORT=18808

# User/Group IDs (optional)
PUID=1000
PGID=1000
⁠3. Update Caddyfile

Edit Caddyfile to match your S3 configuration:

{
    http_port {$CADDY_PORT:80}

    filesystem my-s3-fs s3 {
        bucket your-bucket-name
        region us-east-1

        # endpoint https://s3.us-east-1.amazonaws.com
        # profile <profile>
        # use_path_style
    }
}

http:// {
    file_server {
        browse
        hide .DS_Store ._.DS_Store ._*
        fs my-s3-fs
    }
}
⁠4. Run with Docker Compose
docker-compose up -d

Access the file server at http://localhost:18808 (or your configured WEB_PORT).

⁠Configuration

⁠Environment Variables
VariableDescriptionRequiredDefault
AWS_ACCESS_KEY_IDS3 access key IDYes-
AWS_SECRET_ACCESS_KEYS3 secret access keyYes-
WEB_PORTPort to expose the file serverNo18808
CADDY_PORTInternal Caddy portNo80
PUIDUser ID to run asNo1000
PGIDGroup ID to run asNo1000
⁠Caddyfile Options

The S3 filesystem module supports the following options:

OptionDescription
bucketS3 bucket name
regionS3 region (e.g., us-east-1, ap-singapore)
endpointCustom S3 endpoint URL
profileAWS profile name from credentials file
use_path_styleUse path-style addressing instead of virtual-hosted style

⁠Supported S3-Compatible Services

This configuration works with:

  • Amazon S3 - https://s3.amazonaws.com
  • Tencent Cloud COS - https://cos.{region}.myqcloud.com
  • Alibaba Cloud OSS - https://{region}.aliyuncs.com
  • MinIO - Your MinIO server endpoint
  • Wasabi - https://s3.wasabisys.com
  • DigitalOcean Spaces - https://{region}.digitaloceanspaces.com

⁠Building Locally

To build the Docker image locally:

docker build -t docker-caddy-s3 .

⁠Docker Run (Without Compose)

docker run -d \
  --name docker-caddy-s3 \
  -p 18808:80 \
  -e AWS_ACCESS_KEY_ID=your-access-key \
  -e AWS_SECRET_ACCESS_KEY=your-secret-key \
  -v $(pwd)/Caddyfile:/etc/caddy/Caddyfile \
  docker-caddy-s3

⁠Troubleshooting

⁠Check Container Logs
docker-compose logs -f
⁠Verify S3 Credentials

Ensure your credentials have the necessary permissions:

  • s3:GetObject
  • s3:ListBucket
⁠Common Issues
  1. Connection refused - Check your endpoint URL and network connectivity
  2. Access denied - Verify your IAM permissions and credentials
  3. Bucket not found - Ensure the bucket name and region are correct

⁠License

This project is licensed under the MIT License - see the LICENSE⁠ file for details.

⁠Credits

⁠Contributing

Contributions are welcome! Please feel free to submit a Pull Request. The function is being upgraded

Tag summary

Content type

Image

Digest

sha256:c5ca943ab…

Size

40.7 MB

Last updated

6 months ago

docker pull wisicn/docker-caddy-s3