Skip to content

Problem with serving private signed media from S3 using custom domain media.mydomain.com thru CloudFront.

0

Hi all,

I'm so sorry to bother but im totally lost. Im running wordpress site using plugin called WP Offload Media, pretty much self explanatory - plugin offloads all media to S3 bucket. I also configured the bucket so that the media served thru CloudFront are from custom url - media.mydomain.com. Now to the issue - I would like to serve certain private media using signed URLs using public and private pem keys, but its throwing error and both my hosting and the plugin devs are clueless.

Here is the error: Private offloaded media URLs may be broken. error:1E08010C:DECODER routines::unsupported error:03000098:digital envelope routines::invalid digest

And here's what my hosting sent me:

HTTP/2 403 --> The 403 Forbidden error suggests that the requested resource is restricted or permissions are misconfigured. content-type: application/xml x-amz-bucket-region: eu-central-1 server: AmazonS3 date: Tue, 21 Jan 2025 12:53:33 GMT x-cache: Error from cloudfront --> Indicates that CloudFront could not fetch the resource from the origin (S3 bucket) due to permission issues. via: 1.1 1dfc3a36dcacc62a94ab0f529b92b6c4.cloudfront.net (CloudFront) x-amz-cf-pop: DUB56-P3 -->> Amazon S3 Headers (x-amz-*) These confirm that the request reached the S3 bucket but was denied. x-amz-cf-id: wN5xa2Ro25ESlAz0meHdpgZFlTJ2Vetnt9m8j2Aj4NsBeLAcCofWqg==

Any ideas please?

Regards Alex

2 Answers
0

The issue you're experiencing with serving private signed media from S3 through CloudFront using a custom domain appears to be related to permissions and configuration settings. Here are some potential causes and solutions to consider:

  1. S3 Bucket Policy: Ensure that your S3 bucket policy allows CloudFront to access the objects. The policy should include permissions for the CloudFront service principal to perform the s3:GetObject action on your bucket resources.

  2. CloudFront Distribution Settings: Verify that your CloudFront distribution is correctly configured to use Origin Access Control (OAC) or Origin Access Identity (OAI) to access the S3 bucket securely. OAC is the newer and recommended approach.

  3. Custom Domain Configuration: Make sure that your custom domain (media.mydomain.com) is properly set up in CloudFront as an alternate domain name (CNAME) and that the corresponding SSL certificate is correctly associated with the distribution.

  4. Signed URLs Configuration: Check that the public and private key pair used for generating signed URLs is correctly set up in both CloudFront and your WordPress plugin (WP Offload Media). Ensure that the keys are in the correct format and haven't expired.

  5. CloudFront Behaviors: Review your CloudFront distribution's behaviors to ensure they're configured to forward the necessary headers and query strings required for signed URLs to work properly.

  6. S3 Bucket Encryption: If you're using server-side encryption on your S3 bucket, make sure that CloudFront is configured to handle encrypted objects correctly.

  7. WordPress Plugin Settings: Double-check the WP Offload Media plugin settings to ensure it's correctly configured to work with CloudFront and signed URLs. Make sure the plugin is using the latest version of the AWS SDK and that all necessary IAM permissions are in place.

  8. CloudFront Function or Lambda@Edge: Consider implementing a CloudFront Function or Lambda@Edge to handle any necessary URL rewriting or header modifications that might be required for your specific setup.

To troubleshoot further:

  1. Review CloudFront and S3 access logs to identify the specific requests that are failing.
  2. Temporarily enable more verbose error logging in CloudFront to get more detailed information about the 403 errors.
  3. Test accessing the S3 objects directly (bypassing CloudFront) to isolate whether the issue is with S3 permissions or CloudFront configuration.
  4. Verify that the AWS account IDs and ARNs in your configurations are accurate and up to date.

If the issue persists after checking these points, you may need to engage AWS support or consult with a specialist who has experience with this specific setup to review your entire configuration and identify any misconfigurations or incompatibilities.
Sources
Cloudfront cannot access s3 bucket | AWS re:Post
Serve private content with signed URLs and signed cookies - Amazon CloudFront
Access Denied for Cloudfront to s3 (2025) | AWS re:Post
Access Denied for CloudFront to S3 | AWS re:Post

answered 2 years ago

EXPERT

reviewed 2 years ago

0

Also verify that you have your Cross-Origin Resource Sharing (CORS) policy defined in your S3 Bucket, for further information please see: https://docs.aws.amazon.com/AmazonS3/latest/userguide/cors.html

AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.