Skip to content

CloudFront and S3 return 403 on direct page links

Diagnose CloudFront 403 responses on S3-backed static sites by matching the public path to the object key, cache behavior, and origin authorization.

By Crawlito · 5 min read

In short

  • A missing S3 object can return 403 when the requester lacks s3:ListBucket permission.
  • A distribution's root document and a nested directory index need separate verification.
  • Compare a real deep link, a public asset, and a genuinely missing route before changing permissions.
On this page

If a static site works at its homepage but direct links return 403 through CloudFront, check the object key CloudFront requests from S3. A missing key can produce 403 when the origin identity lacks bucket-list permission. A successful homepage therefore tells you little about whether /guides/install/ reaches the deployed guides/install/index.html object. Amazon S3 GetObject error behavior

Pick an affected guide that you can identify by its title and a line in the body. From a clean client request the distribution root, the public guide path, its explicit index-file path, a known static asset, and a made-up path. Record the response status, type, and distinctive body text for each. A branded CloudFront error page and a branded application error page can look similar in a screenshot.

Build the matching table from the release artifact. A static export may contain guides/install.html, guides/install/index.html, or an application shell for all routes. Each model requires different routing. Open a generated file and verify its contents before adjusting AWS settings. An authenticated operator can inspect whether the expected object key exists in the intended bucket and prefix. A build artifact on a developer machine says nothing about a failed upload.

bash
curl -sS -D guide-headers.txt -o guide-body.html https://example.com/guides/install/
curl -sS -D file-headers.txt -o file-body.html https://example.com/guides/install/index.html

If the explicit public file contains the real guide while the friendly path returns an error, first investigate URI mapping. If both fail but a sibling asset works, check whether the upload omitted the guide, used different capitalization, or sent it to a different release prefix. A case-insensitive development filesystem can hide a broken path that S3 treats as a distinct key.

Identify the origin type and cache behavior

A regular S3 bucket origin accessed through CloudFront is different from an S3 website endpoint configured as a custom origin. AWS documents origin access control for a regular S3 origin and explains that website endpoints cannot use that mechanism. Check the distribution's actual origin and the behavior selected for the failing path. Do not infer those settings from the address in a user's browser. AWS guidance on restricting access to S3 origins

A distribution's default root object can make the site root work while requests inside folders still need explicit mapping to their index objects. Compare the requested viewer path with any origin path prefix and any viewer-request function that rewrites the URI. For example, the release might live under public/ at the origin while the edge configuration prepends another public/. The resulting key is wrong before S3 considers any document content.

Review relevant origin access using your existing authorized tools. S3 documents that an absent object returns 404 to a caller with s3:ListBucket and may return 403 to a caller without it. Granting public bucket-list access to make a diagnostic status change would expose capabilities unrelated to serving the document. Use an authorized inventory or deployment manifest to establish the key's existence and keep the intended access boundary in place.

Fix routing according to the build that shipped

For an export that produces directory indexes, a viewer-request rewrite can map a qualifying friendly path to the matching file. AWS provides a CloudFront Functions example that adds index.html to appropriate requests. Adapt the pattern to the actual distribution and path families. Keep APIs, files with extensions, private downloads, and other behaviors out of a static page rewrite unless their owners explicitly use the same convention. AWS’s directory index rewrite example

If the export uses flat HTML filenames, appending /index.html will ask for another missing key. If it is a client-rendered application, mapping navigation requests to its shell may be intentional, but the shell must still distinguish real routes from missing content. The SPA error status guide explains the separate issue of giving every invented route a successful response. Storefronts and documentation sites can mix these patterns under different path prefixes.

CloudFront can also replace an error body, change the response code returned to the viewer, and cache errors for a configured period. Check those settings when a fixed file continues to produce yesterday's error or every missing asset appears as HTML. Changing a universal 403 handler to return success can hide a real authorization error as easily as a missing file. CloudFront custom errors and caching

Verify the public behavior that visitors and crawlers rely on

Repeat the original requests after release propagation. The real deep link must return the expected page, the asset must return the correct file, a protected object should remain protected, and an unknown public route should accurately communicate its missing state according to your architecture. Record the final body title or another content marker. A success status from the homepage fallback is insufficient evidence of a repaired guide.

Test arriving from an internal navigation click and pasting the same URL into a fresh browser. Client-side routing can render correctly after a click even though a direct request fails before any JavaScript is downloaded. Search tools, people following a shared link, and readers opening a bookmark all depend on the direct route. The HTTP status and redirects guide describes the difference between a transport result and the page a person ultimately sees.

Save the viewer path, resolved object key, selected behavior, and a known good response in the deployment runbook or existing issue. If an export upgrade changes the filename layout again, those four details let the next engineer test the assumption directly. For failures that appear only at some edge locations, compare cache age and invalidation scope using the CDN freshness guide.

Diagnose failures that begin between two deployments

Suppose releases are copied to a new origin prefix before the distribution switches to them. A direct request during the gap can reach an incomplete prefix and receive an error. CloudFront may keep that error for the configured interval even after the missing object arrives. Compare the deployment order, object upload completion, first failing request, and cache behavior. A test against the current bucket contents alone can miss this timing problem.

For the next release, verify the representative deep object and its assets inside the completed release prefix before switching public traffic. Then request the public friendly URL after the switch and check the title marker in the body. Test the explicit file address as a diagnostic if the friendly route fails. If only the cached edge response remains wrong, apply the distribution's established targeted cache procedure for that path. This gives the operator a way to distinguish a missing upload from an old cached error at the same public address.

Frequently asked questions

Does a 403 prove our bucket policy is wrong?

No. The same viewer status can arise from an absent key, a genuine access denial, or a configured edge response. Check the key and the route first.

Should we make the bucket public to test this?

Use the authorized deployment inventory and the existing CloudFront route. You can verify the object layout and distribution behavior while preserving the bucket's intended access model.

Why does the route work after I click inside the app?

Client-side navigation can update the screen without requesting that HTML route from the origin. A pasted address exercises the public routing configuration.

Run the free page check on the actual nested guide. Compare the response and title with the deployed object you identified in the release artifact.

Filed under Platform guides. Topics: aws, cdn, http-status, troubleshooting