Get 404 When Using CloudFront URL


We are using CloudFront with a custom origin. No matter what file we try to access on the CloudFront, we get a 404. For example,

Even if we go to the root of the site at we get a 404.

When the origin server is accessed, the file comes up:

Does anyone have any ideas on what the issue could be?

asked 7 years ago6514 views
2 Answers

Examining the response headers from the error it's clear that the error response is actually being generated by your origin server. A better understanding of the reason for the error should be obtainable by reviewing the origin server's logs. There should be something there that differs from what you assume will be there.

Common causes:

▶ You've misunderstood the purpose of the "Origin Path" setting. This value should usually be left blank. If populated, its value is prepended to the path of each request from the browser, before the request is forwarded to the origin.

▶ Your origin server is not expecting the incoming HTTP Host header that's being sent by CloudFront with each request, and assumes the request is for an unknown/unconfigured site. Specifically, there are two choices for what CloudFront sends to the origin server as the Host header.

If you don't configure a Cache Behavior to whitelist the Host header, CloudFront sends the hostname you configured for Origin Domain Name.

If you do configure a Cache Behavior to whitelist the Host header (or to forward all headers), CloudFront sends the same Host header that was sent into CloudFront by the browser -- the same hostname shown in the browser's address bar -- which would be the distribution hostname in this case, or would be an Alternate Domain Name you've configured on the distribution, if that's the hostname the browser is actually using to make the request in question.

answered 7 years ago

The point has already been pointed out in the earlier response. The origin of this distribution is [], but you have mentioned an "origin path" as well. This means when you access, the following address will be fetched fetched from origin:

How to fix it:
1- Please go to the CloudFront console
2- Select your distribution
3- Go to the "origin" tab
4- Edit the origin
5- Remove the "Origin Path"
6- Save

answered 7 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.

Guidelines for Answering Questions