Blueprints · Docker & Databases
Production
25 min · MinIO / Nginx
MinIO object storage behind Nginx TLS
Keeps the API and console on localhost and publishes them through Nginx on 443. Buckets stay private until a policy says otherwise.
Live config
Baked-in protections
- API 9000 and console 9001 are bound to 127.0.0.1
- Nginx is the TLS endpoint
- The root user password is an environment file with mode 600
- New buckets are not given a public policy by this file
Step 1 · yaml
Compose file
/opt/minio/compose.yaml
The start script refuses the default password.
services:
minio:
image: minio/minio:latest
command: server /data --console-address ":9001"
env_file:
- ./minio.env
ports:
- "127.0.0.1:9000:9000"
- "127.0.0.1:9001:9001"
volumes:
- minio:/data
security_opt:
- no-new-privileges:true
restart: unless-stopped
volumes:
minio:
Step 2 · nginx
Environment and Nginx
/etc/nginx/sites-available/s3.example.com.conf
Private buckets are the MinIO default. Do not add an anonymous policy.
server {
listen 443 ssl;
server_name s3.example.com;
ssl_certificate /etc/letsencrypt/live/s3.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/s3.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
client_max_body_size 0;
ignore_invalid_headers off;
location / {
proxy_pass http://127.0.0.1:9000;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 443 ssl;
server_name s3-console.example.com;
ssl_certificate /etc/letsencrypt/live/s3-console.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/s3-console.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
location / {
proxy_pass http://127.0.0.1:9001;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Step 3 · bash
Env file and start script
/root/portgate-blueprints/minio-write.sh
The start script is written and not executed.
#!/bin/sh set -eu install -d -m 755 "/opt/minio" umask 077 cat > "/opt/minio/minio.env" <<'EOF' MINIO_ROOT_USER=portgate MINIO_ROOT_PASSWORD=change-me EOF chmod 600 "/opt/minio/minio.env" cat > "/opt/minio/up.sh" <<'EOF' #!/bin/sh set -eu if [ "change-me" = "change-me" ]; then echo "Set MINIO_ROOT_PASSWORD first." >&2 exit 1 fi cd "/opt/minio" docker compose up -d EOF chmod 755 "/opt/minio/up.sh" echo "Start script written. It was not run."