support redirection on s3 endpoint #910

Open
trinity-1686a wants to merge 9 commits from trinity-1686a/garage:1686a/s3-redirects into next-v2

fix #665
doesn't fix #547 directly, but allows for request routing with no condition, which in practice is the same, formulated differently in xml config

implement support for aws s3 routing rules which allow to redirect requests.
Also support server side redirect (not shown to user agent). This is inspired by netlify, and could be useful in some scenarios such as:

  • for 200, a single page application that interpret url path from the client side: otherwise it could change the url without reloading the page in a way that reloading the page would result in a 404
  • for 404 (in conjonction with a prefix, and a condition on return code), having different 404 pages for different situations, for instance a french 404 page for urls starting in /fr/, but a german page on urls starting in /de/
fix #665 doesn't fix #547 directly, but allows for request routing with no condition, which in practice is the same, formulated differently in xml config implement support for aws s3 routing rules which allow to redirect requests. Also support server side redirect (not shown to user agent). This is inspired by netlify, and could be useful in some scenarios such as: - for 200, a single page application that interpret url path from the client side: otherwise it could change the url without reloading the page in a way that reloading the page would result in a 404 - for 404 (in conjonction with a prefix, and a condition on return code), having different 404 pages for different situations, for instance a french 404 page for urls starting in /fr/, but a german page on urls starting in /de/
trinity-1686a added the
kind
improvement
label 2024-12-14 16:58:15 +00:00
trinity-1686a added 1 commit 2024-12-14 16:58:15 +00:00
support redirection on s3 endpoint
Some checks failed
ci/woodpecker/pr/debug Pipeline failed
c9b733a4a6
trinity-1686a added 2 commits 2024-12-22 14:26:10 +00:00
clippy
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful
c939d2a936
lx added 1 commit 2025-01-04 16:06:02 +00:00
remove obsolete RedirectAll struct
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful
6ccfbb2986
lx added 1 commit 2025-01-04 17:22:59 +00:00
move Redirect::compute_target to standalone function in web_server.rs
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful
22487ceddf
lx added 1 commit 2025-01-04 17:51:05 +00:00
properly implement new bucket model using a migration
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful
44ce6ae5b4
lx added 1 commit 2025-01-04 18:16:43 +00:00
put bucket website: improve error message for redirectallrequests
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful
9b7fea4cb0
lx added 1 commit 2025-01-04 18:51:16 +00:00
avoid handling status_code-related logic in api/s3/get.rs
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful
dde02b9678
lx force-pushed 1686a/s3-redirects from dde02b9678 to cd62450aeb 2025-01-04 18:52:05 +00:00 Compare
lx force-pushed 1686a/s3-redirects from cd62450aeb to 47467df83e 2025-01-04 18:52:20 +00:00 Compare
lx added 1 commit 2025-01-04 19:12:05 +00:00
refactor web_server.rs
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful
2aaba39ddc
Owner

@trinity-1686a I pushed a few changes, could you review them ?

  • Revert changes in api/s3/get.rs and instead implement the status-code-specific logic in a new function handle_inner in web_server.rs. This makes the change less invasive and condenses the logic in a single place which IMO makes it easier to debug

  • Make the changes to the bucket table a migration to a v2 of the model. This means that this change will be released with Garage v2, and not earlier, because we expect all v1.x garage damons to be seamlessly compatible within a same cluster but with this change it cannot be the case.

@trinity-1686a I pushed a few changes, could you review them ? - Revert changes in api/s3/get.rs and instead implement the status-code-specific logic in a new function handle_inner in web_server.rs. This makes the change less invasive and condenses the logic in a single place which IMO makes it easier to debug - Make the changes to the bucket table a migration to a v2 of the model. This means that this change will be released with Garage v2, and not earlier, because we expect all v1.x garage damons to be seamlessly compatible within a same cluster but with this change it cannot be the case.
lx changed target branch from main to next-v2 2025-01-04 19:21:19 +00:00
lx added this to the v2.0 milestone 2025-01-27 12:53:09 +00:00
All checks were successful
ci/woodpecker/pr/debug Pipeline was successful
This pull request has changes conflicting with the target branch.
  • src/api/admin/bucket.rs
  • src/api/s3/website.rs
  • src/garage/admin/bucket.rs
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 1686a/s3-redirects:trinity-1686a-1686a/s3-redirects
git checkout trinity-1686a-1686a/s3-redirects

Merge

Merge the changes and update on Forgejo.
git checkout next-v2
git merge --no-ff trinity-1686a-1686a/s3-redirects
git checkout trinity-1686a-1686a/s3-redirects
git rebase next-v2
git checkout next-v2
git merge --ff-only trinity-1686a-1686a/s3-redirects
git checkout trinity-1686a-1686a/s3-redirects
git rebase next-v2
git checkout next-v2
git merge --no-ff trinity-1686a-1686a/s3-redirects
git checkout next-v2
git merge --squash trinity-1686a-1686a/s3-redirects
git checkout next-v2
git merge --ff-only trinity-1686a-1686a/s3-redirects
git checkout next-v2
git merge trinity-1686a-1686a/s3-redirects
git push origin next-v2
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Deuxfleurs/garage#910
No description provided.