Skip to content

Download URLs are not working as expected when using PREFIX_LEADING_DIRECTORY_PATH #480

@lapwat

Description

@lapwat

Bug Overview

When I use

ALLOW_DIRECTORY_LIST: true
PREFIX_LEADING_DIRECTORY_PATH: /subfolder/to/expose/

I get the following HTML table:

<body>
  <h1>Index of /subfolder/to/expose/</h1>
  <hr />
  <table id="list">
    <thead>
      <tr>
        <th style="text-align: left; width:55%">Filename</th>
        <th style="text-align: left; width:20%">File Size</th>
        <th style="text-align: left; width:25%">Date</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a href="../">..</a></td>
      </tr>
      <tr>
        <td><a href="/subfolder/to/expose/seethis">seethis/</a></td>
        <td></td>
        <td></td>
      </tr>
    </tbody>
  </table>
</body>
  • If I click on the link /subfolder/to/expose/seethis, I get a No Files Available for Listing page
  • The page /seethis works by entering the URL manually

Expected Behavior

I expect the href of all the links in the link to be striped by the PREFIX_LEADING_DIRECTORY_PATH variable, like this:

        <td><a href="/seethis">seethis/</a></td>

As a bonus, the title of the page can be stripped too.

  <h1>Index of /</h1>

So that the prefix path is hidden.

Steps to Reproduce the Bug

Expose a bucket with this config:

ALLOW_DIRECTORY_LIST: true
PREFIX_LEADING_DIRECTORY_PATH: /subfolder/to/expose/

Environment Details

  • Version of the S3 container used: [DockerHub/GCR]: ghcr.io/nginx/nginx-s3-gateway/nginx-oss-s3-gateway:latest-20251201
  • Commit/Tag (if building the NGINX S3 gateway from source): N/A
  • Version of NGINX Open Source or NGINX Plus: [OSS/Plus] OSS
  • Version of NGINX JavaScript: [0.8.8/0.8.7/etc...]
  • Target deployment platforms [e.g. AWS/GCP/local cluster/etc...]: Kubernetes
  • S3 backend implementation: [e.g. AWS, Ceph, NetApp StorageGrid, etc...] GCP
  • Authentication method: [e.g. IAM, IAM with Fargate, IAM with K8S, AWS Credentials, etc...] AWS Credentials

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions