Cloudfront custom-origin distribution returns 502 “ERROR The request could not be satisfied.” for some URLs

后端 未结 14 2559
旧巷少年郎
旧巷少年郎 2020-12-07 15:32

We have a Cloudfront distribution with custom origin that has been working just fine for quite a long time, serving static assets for one of our sites. Just this morning, we

相关标签:
14条回答
  • 2020-12-07 15:54

    Beware the Origin Protocol Policy:

    For HTTPS viewer requests that CloudFront forwards to this origin, one of the domain names in the SSL certificate on your origin server must match the domain name that you specify for Origin Domain Name. Otherwise, CloudFront responds to the viewer requests with an HTTP status code 502 (Bad Gateway) instead of returning the requested object.

    In most cases, you probably want CloudFront to use "HTTP Only", since it fetches objects from a server probably hosted with Amazon too. No need for additional HTTPS complexity at this step.

    Note that this is different to the Viewer Protocol Policy. You can read more about the differences between the two here.

    0 讨论(0)
  • 2020-12-07 15:56

    I ran into this problem, which resolved itself after I stopped using a proxy. Maybe CloudFront is blacklisting some IPs.

    0 讨论(0)
  • 2020-12-07 15:57

    In my case, it was because we had an invalid ssl cert. The problem was on our staging box and we use our prod cert on that as well. It had worked for the past couple of years with this configuration, but all of a sudden we started getting this error. Strange.

    If others are getting this error, check that the ssl certificate is valid. You can enable logging to s3 via the AWS CloudFront Distribution interface to aid debugging.

    Also, you can refer to amazon's docs on the matter here: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/SecureConnections.html

    0 讨论(0)
  • 2020-12-07 16:00

    One more possible solution: I have a staging server that serves the site and the Cloudfront assets over HTTP. I had my origin set to "Match Viewer" instead of "HTTP Only". I also use the HTTPS Everywhere extension, which redirected all the http://*.cloudfront.net URLs to the https://* version. Since the staging server isn't available over SSL and Cloudfront was matching the viewer, it couldn't find the assets at https://example.com and cached a bunch of 502s instead.

    0 讨论(0)
  • 2020-12-07 16:00

    In my case, I use nginx as reverse-proxy for an API Gateway URL. I got same error.

    I resolved the issue when I added the following two lines to the Nginx config:

    proxy_set_header Host "XXXXXX.execute-api.REGION.amazonaws.com";
    proxy_ssl_server_name on;
    

    Source is here: Setting up proxy_pass on nginx to make API calls to API Gateway

    0 讨论(0)
  • 2020-12-07 16:00

    In our case, we had dropped support for SSL3, TLS1.0, and TLS1.1 for PCI-DSS compliance on our origin servers. However, you have to manually add support for TLS 1.1+ on your CloudFront origin server config. The AWS console displays the client-to-CF SSL settings, but does not easily show you CF-to-origin settings until you drill down. To fix, in the AWS console under CloudFront:

    1. Click DISTRIBUTIONS.
    2. Select your distro.
    3. Click ORIGINS tab.
    4. Select your origin server.
    5. Click EDIT.
    6. Select all protocols that your origin supports under "Origin SSL Protocols"
    0 讨论(0)
提交回复
热议问题