This is an example of how to use Minio with Laravel and Docker, using https everywhere with self signed SSL certificates (aka : Hard Mode).
It supports Temporary URLs to access the files stored in Minio, and temporary Upload URLs to upload files directly to Minio.
- Docker and Docker-Compose (included with Docker Desktop)
- mkcert (or your own self signed SSL certificates)
This project uses Docker-Compose to run the following services:
- haproxy : A reverse proxy that handles SSL termination and forwards requests to the appropriate service (Laravel or Minio). It could easily be replaced with Traefik, Caddy, or NginX.
- php : A PHP container running Laravel 11 through
php artisan serve
- minio : Our S3 compatible object storage server
We use three different domains to access the services:
https://minio-console.test
: The Minio web consolehttps://minio-api.test
: The Minio APIhttps://laravel.test
: The Laravel application
The only port that's exposed from the Docker containers is port 443 on the HAproxy container. It means that requests to all domains need to be in HTTPS and will go through the reverse proxy.
Since we want to use https everywhere, it also means that requests to https://minio-api.test from within the docker network needs to be forwared to that container (this is done with haproxy.network.default.aliases
in the docker-compose file).
- Clone the repository
- Create an SSL certificate with mkcert, combine the certificate and key into an
haproxy.pem
file, and place it in them in the.docker/certs
folder along with therootCA.pem
. You can do this by running the following commands:mkcert -install mkcert -cert-file minio-cert.pem -key-file minio-key.pem minio-console.test minio-api.test laravel.test cat minio-cert.pem minio-key.pem > .docker/certs/haproxy.pem cp $(mkcert -CAROOT)/rootCA.pem .docker/certs/
- copy the env file :
cp .env.example .env
- Add the following to your hosts file :
127.0.0.1 minio-console.test 127.0.0.1 minio-api.test 127.0.0.1 laravel.test
- Run
docker run --rm --interactive --tty --volume $PWD:/app composer install
to install the composer dependencies - Run
docker-compose up -d
to start the servives as daemons - Run
docker-compose exec php bash -c "touch /var/www/html/database/database.sqlite && php /var/www/html/artisan key:generate && php /var/www/html/artisan migrate"
to create a database, app key, and run the migrations - Create a bucket called
mybucket
. You can do it either :- Through the API : Run
docker-compose exec minio mc mb myminio/mybucket
in your terminal. - Through the web UI : Go to
https://minio-console.test
in your browser, login with the credentials (admin
/password
), and create the bucket.
- Through the API : Run
- Open
https://laravel.test
in your browser, you should be able to upload a png file to the bucket through a temporary upload URL, and then see it displayed through a temporary URL.