question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set default URL for presignedUrl

See original GitHub issue

In 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 :

  1. A minio container on minio:9000
  2. A server API container on api:3000
  3. Instantiate minio and set the endpoint/port to minio’s container.
  4. 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:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

32reactions
harshavardhanacommented, Oct 6, 2016

Yes, of course but how we can say to minio to give a proxy URL instead of a local one ? My code transform a local minio URL into a proxy url.

You have to use the proxy URL as part of ‘minioClient’ basically the endpoint is already the proxy URL.

23reactions
ghostcommented, May 6, 2019

@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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sharing objects using presigned URLs - AWS Documentation
Describes how to set up your objects so that you can share them with others by creating a presigned URL to download the...
Read more >
Generate Pre signed URL for File Upload with Public Access
I have a bucket with default ACL set to private. I want to generate pre signed url and distribute it to user so...
Read more >
Generating a presigned URL to upload an object - 亚马逊云科技
All objects and buckets by default are private. The presigned URLs are useful if you want your user/customer to be able to upload...
Read more >
Securing AWS S3 uploads using presigned URLs - Medium
By default, all objects are private — meaning only the bucket ... AWS gives access to the object through the presigned URL as...
Read more >
Working with S3 pre-signed URLs | Altostra
The default pre-signed URL expiration time is 15 minutes. Make sure to adjust this value to your specific needs. Security-wise, you should ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found