Set default URL for presignedUrl
See original GitHub issueIn a docker-compose file I build :
- minio => minio:9000
- api => api:3000
- nginx => 0.0.0.0:80
The nginx redirections :
- 0.0.0.0/ => minio:9000
- 0.0.0.0/api => api:3000
Expected behaviour
When requesting the API for a resource, the API should return a public URL to access to it not the container’s address.
Actual behaviour
The API returns a presigned url built with the docker address and not the public address. If I edit the returned host with the public host the key mismatch and I can’t access to the resource.
Steps to reproduce the behaviour
Run a docker with these containers :
- A minio container on minio:9000
- A server API container on api:3000
- Instantiate minio and set the endpoint/port to minio’s container.
- A nginx server on 80 redirecting / to minio and /api to the API
How I fixed it
To fix this issue I setup my nginx to modify the host :
location / {
proxy_set_header Host minio:9000;
proxy_pass http://minio:9000;
}
And on the API side I rewrite the host before sending the presignedUrl :
MinioStorage.prototype.getURL = function(bucketName, filename, cb, expiry) {
expiry = expiry || 3600*24*2; // 2 days
var self = this;
this.minioClient.presignedGetObject(bucketName, filename, expiry, function(err, presignedUrl) {
if(cb) {
cb(err, {
container: bucketName,
filename: filename,
url: presignedUrl.replace(self.internalURL, self.publicURL)
});
}
});
};
Minio version
RELEASE.2016-09-11T17-42-18Z
What to do ?
Minio client configuration
I think it could be nice to customize the public url that minio should use to generate presignedUrl directly when a client instantiate the minioClient.
Something like :
this.minioClient = new Minio({
endPoint: ...,
port: ...,
secure: ...,
accessKey: ...,
secretKey: ...,
publicUrl: 0.0.0.0 /* Here the URL I want to use in presigned url */
});
Docker configuration
Or, add a Environment variable to allow docker to inject to it : PUBLIC_URL
Thank you.
Opened from https://github.com/minio/minio/issues/2848
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
You have to use the proxy URL as part of ‘minioClient’ basically the endpoint is already the proxy URL.
@harshavardhana it is very uncommon for docker services that they aren’t aware of their own publicly reachable URL/host to return proper URLs directly. so since nobody has suggested it yet, I suggest to revisit this based on that fact, if alone that most other containers have such an option and I just spend a while googling around assuming I was blind until I found this here
in addition, this seems like something that wouldn’t add much complexity to the server, and it is wasting people’s time because everyone needs to invest coding their app/proxy to replace things to give out a proper URL that works (and of course this isn’t hard, and most people will run a proxy anyway, but it’s just a time sink compared to most other docker services being fine with a single env option to make this work)