0

I have a page that displays deep zoom images that are stored in an Amazon S3 account. The image URLs are created like this in the controller:

imageUrl = "http://" + image.TileBucketNum + ".img.americanancestors.org/" + image.FileGuid.Trim().ToLower() + ".xml";

which produces something like "http://83.img.mywebsite.org/8985cb7f-0795-4ff6-bfd1-c2a27bf0963d.xml"

Once we installed an SSL certificate onto our site, the image pages stopped working because of a mixed content error:

'mywebsite.org' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://83.img.mywebsite.org/8985cb7f-0795-4ff6-bfd1-c2a27bf0963d.xml'.

I tried changing the image URL to https, but if I just change it to 'https://83.img.mywebsite.org/....' the image fails to load; if I try to go to that URL directly (which, with http, automatically downloads the image), I get a security warning page.

I tried the suggestion on this post and tried using this URL:

'https://s3.amazonaws.com/83.img.mywebsite.org/images/8985cb7f-0795-4ff6-bfd1-c2a27bf0963d.xml'

but that returns an "Access Denied" message. How can I load my S3 images on an HTTPS page?

Community
  • 1
  • 1
Erica Stockwell-Alpert
  • 4,624
  • 10
  • 63
  • 130

1 Answers1

0

ok, will try to clear your situation little bit

First of all I suppose that you use s3 storage without CloudFront and when you used the link http://83.img.mywebsite.org/8985cb7f-0795-4ff6-bfd1-c2a27bf0963d.xml, you uses CNAME (Customizing Amazon S3 URLs with CNAMEs http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLs) to s3

Then you referred to the post How to Configure SSL for Amazon S3 bucket that explains how to use custom SSL for CloudFront that looks like you didn't use

Then when you tried https://s3.amazonaws.com/83.img.mywebsite.org/images/8985cb7f-0795-4ff6-bfd1-c2a27bf0963d.xml' I suppose you putted the subdomain "83.img.mywebsite.org" to the place where actually your bucket name should be placed (but possible you have same bucket name). Also i'm confused about "images" path that you didn't mentioned in first link.

Conclusion: You didn't specify which language do you use, but it is better to use AWS SDK and method "getObjectUrl" to generate proper link to s3 object.

For example for PHP you can download http://aws.amazon.com/sdk-for-php/

and do something like:

use Aws\S3\S3Client;

$bucket = '*** Your Bucket Name ***';

// Instantiate the client.
$s3 = S3Client::factory();
$plainUrl = $client->getObjectUrl($bucket, 'data.txt');
Community
  • 1
  • 1
Evgeniy Kuzmin
  • 2,384
  • 1
  • 19
  • 24