How do I set the minio domain for pre-signed URLs? How do I set the minio domain for pre-signed URLs? kubernetes kubernetes

How do I set the minio domain for pre-signed URLs?


I bashed my head on this problem for a couple of days and managed to resolve it with NGINX in my Kubernetes cluster.

NGINX controller Kubernetes: need to change Host header within ingress

You use the ingress annotations to change the Host header of all incoming traffic to your Minio ingress so that it will always be the same Host name.


It all depends on how you create your Minio client instance. Specifying host and port as below will make Minio resolve your domain to IP address and use IP rather than the domain. Sample JavaScript code:

import { Client as MinioClient } from 'minio';const client = new MinioClient(  endPoint: 'yourdomain.com',  port: 9000,  accessKey: process.env.MINIO_ACCESS_KEY,  secretKey: process.env.MINIO_SECRET_KEY,  useSSL: false);

If you create your minio instance like above, your domain will be resolved to it's corresponding IP address, and thus minio will work with http://x.x.x.x:9000 as opposed to https://yourdomain.com

Also to note, if your client is configured as above, trying to use useSSL: true will throw SSL error as below

write EPROTO 140331355002752:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332

For minio to use your domain as https://yourdomain.com, you need to have a web server like nginx to proxy your requests to your minio server. Minio has documented how you can achieve this here. Add SSL to your domain as documented here then proceed to create your minio client as below:

import { Client as MinioClient } from 'minio';const client = new MinioClient(  endPoint: 'yourdomain.com',  port: 443,  accessKey: process.env.MINIO_ACCESS_KEY,  secretKey: process.env.MINIO_SECRET_KEY,  useSSL: true);

Note the change in port and useSSL parameters.

Minio will now use https://yourdomain.com in all cases. Signed urls will also be https.