imazen / imageflow-dotnet-server

A super-fast image server to speed up your site - deploy as a microservice, serverless, or embeddable.
https://docs.imageflow.io
GNU Affero General Public License v3.0
252 stars 33 forks source link

Configuring S3 with CloudFront #39

Closed timheuer closed 3 years ago

timheuer commented 3 years ago

I'm trying to interpret the config instructions for use with CloudFront instead of direct buckets in the S3 configuration?

Also is the AddImageflowRemoteReaderService required if only using the S3 provider?

lilith commented 3 years ago

Are you trying to use CloudFront in front of Imageflow or behind it? If in front, you would set the custom origin to be the Imageflow server. If behind, then you would use the RemoteReader service for plain HTTP requests. The S3 provider does not connect to cloudfront, only regular s3 buckets.

That said, I doubt that using CloudFront behind of Imageflow and in front of S3 would really help much, so it's probably better to just use the S3 provider. If you're just using s3 directly, you do not need the RemoteReaderService.

timheuer commented 3 years ago

Thanks @lilith for the prompt response!

I'm looking to add this to existing project where the content is already referenced as https:[cloudfronturi]/image.jpg -- and NOT looking to change back content URIs. It sounds like perhaps this may not be for my use case then?

lilith commented 3 years ago

I'm not sure I follow what your scenario is yet. Could you offer some example content urls and what behavior you would like to see?

On Tue, Dec 15, 2020, 12:50 PM Tim Heuer notifications@github.com wrote:

Thanks @lilith https://github.com/lilith for the prompt response!

I'm looking to add this to existing project where the content is already referenced as https:/image.jpg -- and NOT looking to change back content URIs. It sounds like perhaps this may not be for my use case then?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow-dotnet-server/issues/39#issuecomment-745526736, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH2FKW7IREJ6TERYKILSU64ZHANCNFSM4U4ZMSMQ .

timheuer commented 3 years ago

Sure. My site is timheuer.com but images in the content are

Where storage2.timheuer.com is a CloudFront CDN to a bucket.

lilith commented 3 years ago

Well, in that case you could edit CloudFront to point to an Imageflow server using the custom origin feature, and the Imageflow server to use the S3 bucket.

Then you wouldn't have to change any content URLs. How would you plan on communicating image sizes and formats though? You could set commands that would apply to all images if there is no querystring I suppose, using the Rewrite event handler. Or we could work on using client hints.

If you have to edit URLs in content anyway, though, I would create a new CloudFront distribution pointing to Imageflow which points to S3, and just change the URLs when you add the querystrings.

timheuer commented 3 years ago

Got it, thanks. I think for my workflow this isn't ideal yet. As you note, the client hints would help here, but you're right that I'd have to set commands and doesn't make sense for all images. Anyhow, this is good to better understand. Just not for me right now in my existing workflow. Definitely on future projects though!!!