Amazon's Cloudfront CDN requires correct connection to your origin in order to work properly without any 502 bad gateway error.

I did setup everything alright.

For example: Cloudfront URL: https://d1u2h2xwg5v1gz.cloudfront.net/wp-content/uploads/2018/11/smartphone-security-guide-1.jpeg (502 Error) My origin URL: https://www.techlegends.in/wp-content/uploads/2018/11/smartphone-security-guide-1.jpeg (Origin)

As per the SSL test (in reference to this guide: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/http-502-bad-gateway.html) - the origin name does satify the condition.

  • Is there anything in your origin server's log files? Nov 29, 2018 at 10:51
  • Let me check that out.
    – ankush
    Nov 29, 2018 at 11:12
  • Nope, there's nothing weird in my origin server's log files. Everything's good. You can run a check on my domain using any tool - you'll find all the SSL certificates/protocols and ports are working. Port 80 forwarding requests to HTTPS is also there - so there's nothing that is blocking or rejecting Cloudfront's CDN.
    – ankush
    Nov 29, 2018 at 11:18
  • Any correlation of not loading with image size? Nov 29, 2018 at 11:42
  • I don’t think so. I’ll try to forcefully purge the cache of the CDN and see whether it’s just for images or every asset on my domain. Will keep this thread updated, thanks for your time!
    – ankush
    Nov 29, 2018 at 11:50

1 Answer 1


I was struggling a bit with owned SSL Certificate and custom settings, but the following article really helped a lot: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/tutorial-redirecting-dns-queries.html

Just had to read with attention to details... 502 bad gateway can be thrown only if the target is not reachable. Double check the origin and access permissions on the target (I e. The origin)

  • It would be helpful if you put a summary of the solution in the answer as link only answers can be problematic if that links rots away.
    – John Conde
    Mar 7, 2019 at 19:22
  • @John unfortunately it's quite complex overall with setting up S3+CF, and the description doesn't define settings used - hard to know exactly what is wrong. But he's right in one thing - that's definitely an incorrect origin. 502 can be thrown only if the recipient is down or not reachable. CF doesn't find it there where it goes. My case was the same.
    – magnump0
    Mar 7, 2019 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.