Skip to content

Frequent 404 on getting same files #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
muhsinkamil opened this issue May 15, 2025 · 1 comment
Open

Frequent 404 on getting same files #402

muhsinkamil opened this issue May 15, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@muhsinkamil
Copy link

Bug Overview

I'm using the nginxinc/nginx-s3-gateway Docker image as a proxy layer to serve static frontend files stored in a private S3 bucket. The container is running with the correct IAM role and is able to access the S3 bucket.

However, when I configure a custom location block like the following:

location ^~ /my-page {
    try_files $uri $uri/ @s3;
}

I frequently encounter 404 errors when accessing paths like /my-page or /my-page/index.html. It appears that the S3 gateway is not correctly resolving the URI or falling back as expected.

Would appreciate any guidance on whether this is a misconfiguration or an issue with how the S3 gateway handles rewrites and try_files.

  • Files do exist in S3 with paths like my-page/index.html
  • IAM role and permissions are correctly configured (files are accessible when requested directly via correct S3 path)
  • The 404s appear inconsistently depending on the request path

Below is the full config for reference:

Dockerfile:

FROM nginxinc/nginx-s3-gateway:latest

COPY js_fetch_trusted_certificate.conf /etc/nginx/templates/gateway/js_fetch_trusted_certificate.conf.template
COPY rules.conf /etc/nginx/templates/gateway/s3_server.conf.template

js_fetch_trusted_certificate.conf:

js_fetch_trusted_certificate /etc/ssl/certs/Amazon_Root_CA_1.pem;

rules.conf:

location /my-page {
    try_files $uri $uri/ @s3;
}

Expected Behavior

Route to map to correct s3 files and be accessible all the time

Steps to Reproduce the Bug

  • S3 bucket with private access
  • Container with IAM role
  • Build docker container like an attached Dockerfile and custom rules

Environment Details

  • Version of the S3 container used:
    Latest: https://hub.docker.com/r/nginxinc/nginx-s3-gateway
  • Target deployment platforms [e.g. AWS/GCP/local cluster/etc...]: AWS
  • S3 backend implementation: [e.g. AWS, Ceph, NetApp StorageGrid, etc...]: AWS
  • Authentication method: [e.g. IAM, IAM with Fargate, IAM with K8S, AWS Credentials, etc...]
    IAM with K8s

Additional Context

No response

@muhsinkamil muhsinkamil added the bug Something isn't working label May 15, 2025
@dekobon
Copy link
Collaborator

dekobon commented May 21, 2025

With this change merged, I'd like for you to update your S3 gateway version to the latest, and try again.

I'm not confident that it will fix the problem, but I can imagine that this issue could be coming from DNS resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants