Install MinIO Object Storage on VPS Instead of AWS S3
MinIO is a high-performance object storage that uses the same S3 API as Amazon S3, making it easy to migrate from S3 with minimal code changes. Install it on your own VPS to save significantly on cloud storage costs and bandwidth. It's perfect for storing user uploads, database backups, static assets, and Docker images.
Install MinIO with Docker Compose
mkdir -p ~/minio/data
cd ~/minio
cat > docker-compose.yml << 'EOF'
version: "3.8"
services:
minio:
image: minio/minio:latest
container_name: minio
restart: unless-stopped
ports:
- "9000:9000" # S3 API
- "9001:9001" # Web console
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: yourStrongPassword123
volumes:
- ./data:/data
command: server /data --console-address ":9001"
EOF
docker compose up -d
Set Up Nginx Reverse Proxy for MinIO
sudo nano /etc/nginx/sites-available/minio
server {
listen 443 ssl;
server_name minio.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/minio.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/minio.yourdomain.com/privkey.pem;
# S3 API
location / {
proxy_pass http://localhost:9000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 1024m;
}
}
server {
listen 443 ssl;
server_name console.minio.yourdomain.com;
# Web console
location / {
proxy_pass http://localhost:9001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Using MinIO Client (mc)
# Download mc
curl -O https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
sudo mv mc /usr/local/bin/
# Set up alias
mc alias set myminio https://minio.yourdomain.com minioadmin yourStrongPassword123
# Create buckets
mc mb myminio/uploads
mc mb myminio/backups
# Upload files
mc cp /path/to/file.zip myminio/backups/
# List files in bucket
mc ls myminio/backups/
Using MinIO with Laravel (Example)
# .env
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=yourStrongPassword123
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=uploads
AWS_ENDPOINT=https://minio.yourdomain.com
AWS_USE_PATH_STYLE_ENDPOINT=true
# filesystems.php
's3' => [
'driver' => 's3',
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => true,
...
]
Configure Bucket Policy and Versioning
After creating a bucket, you should set a clear access policy and enable versioning to recover files that were overwritten or accidentally deleted:
# Set up alias to our MinIO instance
mc alias set myminio https://s3.yourdomain.com ACCESS_KEY SECRET_KEY
# Enable versioning (recover old files)
mc version enable myminio/backups
# Set bucket to private (default) or download-only
mc anonymous set download myminio/public-assets
mc anonymous set none myminio/backups
# Set up lifecycle to automatically delete old objects after 90 days
mc ilm rule add --expire-days 90 myminio/temp-uploads
Verify MinIO is Working Correctly
# Check container status
docker compose ps
# Check API endpoint
curl -I https://minio.yourdomain.com/minio/health/live
# Test upload/download
mc cp /etc/hostname myminio/backups/test.txt
mc ls myminio/backups/
mc rm myminio/backups/test.txt
/minio/health/live returns 200 when the service is ready. Use it immediately in Uptime Kuma or monitoring tools.
Common Issues & Troubleshooting
Error: "SignatureDoesNotMatch" When Connecting from SDK
The region in your SDK must match the region set in MinIO. If using a custom region, ensure they match, or use us-east-1 which is the default:
mc admin info myminio | grep -i region
Large File Upload Fails (413 Entity Too Large)
Nginx has a client_max_body_size limit — add it to your nginx config:
# /etc/nginx/sites-available/minio
client_max_body_size 10240m; # 10GB
sudo nginx -t && sudo systemctl reload nginx
MinIO Console Won't Open (WebSocket Error)
The console uses WebSocket and requires the proxy to support upgrade headers:
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 900s;
Frequently Asked Questions
Does MinIO Support Versioning Like S3?
Yes, MinIO supports S3 versioning. Enable it with mc version enable myminio/bucketname. This stores the file change history and allows you to restore old versions instantly.
How Much Does MinIO Save Compared to AWS S3?
AWS S3 costs $0.023/GB/month plus bandwidth and request charges. MinIO on a VPS costs only the fixed VPS fee. For 100 GB+ of storage per month, MinIO is typically much cheaper, especially if the VPS is already running other services.
How Do I Back Up MinIO?
Use mc mirror to perform cross-site backup or sync with real S3 for offsite backup: mc mirror myminio/important s3/backup-bucket --watch