oxyno-zeta / s3-proxy

S3 Reverse Proxy with GET, PUT and DELETE methods and authentication (OpenID Connect and Basic Auth)
https://oxyno-zeta.github.io/s3-proxy/
Apache License 2.0
284 stars 31 forks source link

Docs for Key rewrite show invalid example with bucket prefix #441

Closed JuroOravec closed 2 months ago

JuroOravec commented 3 months ago

Description

The docs for key rewrite suggest the following:

Given this config:

targets:
  - name: test
    # ...
    keyRewriteList:
      - source: ^/file.html$
        target: /redirected/file.html
    bucket:
      # ...
      prefix: "/folder1"

Then GET /file.html should be rewritten to GET /folder1/redirected/file.html.

HOWEVER, it seems that currently, the source regex MUST account also for the prefix.

So, to redirect from /file.html to /folder1/redirected/file.html, given a bucket prefix /folder1, we need to do:

targets:
  - name: test
    # ...
    keyRewriteList:
      - source: ^/folder1/file.html$
        target: /folder1/redirected/file.html
    bucket:
      # ...
      prefix: "/folder1"

The reason for this is because in the code, currently the logic to get the full path including the prefix is called BEFORE the regex matching logic. See https://github.com/oxyno-zeta/s3-proxy/blob/8f1e39b3589171bfd94e1d25cd85c4b8c19e5374/pkg/s3-proxy/bucket/bucket-req-impl.go#L131

Describe the solution you'd like

Update the docs to include the correct examples.

oxyno-zeta commented 3 months ago

Hello,

Thanks for this issue. Yes, documentation is wrong and must be updated.

Oxyno-zeta

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days

JuroOravec commented 2 months ago

Not stale

oxyno-zeta commented 2 months ago

I've fixed the documentation. Thanks for the issue !