title: Can't configure AWS Lightsail distribution - status 502
body: <p>I've setup Lightsail/Bitnami wordpress instance in AWS. Assigned a static IP and set it up in cloudflare DNS with my xyz.com domain. Ran the bncert-tool to validate the domain name against this instance.</p>
  <p>Later I decided to add CDN to this instance as woocommerce was slowing it down.  Started a distribution.  Selected wordpress configuration for caching and selected 'HTTPS only.' (This is where it goes wrong). Distribution starts up. When I click on the default domain of the distrbution abcdef.cloudflare.com i just get errors:</p>
  <pre><code>502 ERROR
  The request could not be satisfied.
  CloudFront wasn't able to connect to the origin. We can't connect to the server for 
  this app or website at this time. There might be too much traffic or a configuration 
  error. Try again later, or contact the app or website owner.
  If you provide content to customers through CloudFront, you can find steps to 
  troubleshoot and help prevent this error by reviewing the CloudFront documentation.
  </code></pre>
  <p>I tried setting the wp-config file with the redirection below and restart apache [sudo /opt/bitnami/ctlscript.sh restart apache] but doesnt do anything.</p>
  <pre><code>if (isset($_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'])
  &amp;&amp; $_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'] === 'https') {
  $_SERVER['HTTPS'] = 'on';
  }
  </code></pre>
  <p>Previously I tried to create CNAME entries in cloudflare to validate the distribution ownership.  Created custom credentials using the distribution page's tool to validate xyz.com, then point xyz.com domains in the DNS over to the distribution's default domain with a CNAME entry.</p>
  <p>502 errors and other random gremlin errors e.g. too many redirects error, etc.,  when I tinker with the settings through trial and error.</p>
  <p>What should I be doing - I seem to have slipped through the help file documentation.  Please help.</p>