GAV
GAV

Reputation: 1213

cloud front always returns 404 error to browser, how to do I make it return 200

Are there settings or configuration options, I can change in cloud front, because it's returning 404 error response, but the code and pages are fine.

Upvotes: 0

Views: 1903

Answers (3)

GAV
GAV

Reputation: 1213

actually found that my nginx.conf was missing something cloud front was looking for

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Upvotes: 0

Edcel Cabrera Vista
Edcel Cabrera Vista

Reputation: 1114

You can utilize AWS Cloudfront Custom Error Response. You can specify HTTP Error Code to be returned by the service when your custom origin is unavailable and returning 4xx, 5xx responses.

You can even set a custom page (page from s3) to be display e.g. 404 html page.

enter image description here

Upvotes: 1

Chris Williams
Chris Williams

Reputation: 35238

It will be using the same http status code that the origin responds.

In saying this you can modify it by using a Lambda@Edge function to change the status code.

Additional Links

Upvotes: 0

Related Questions