New directive tricot-add-redirect <match-prefix> <redirect-prefix> [301|302|303|307] #10

Merged
quentin merged 4 commits from redirect into main 2023-11-29 16:09:56 +00:00
Owner

Roadmap

  • Update proxy_config.rs to fetch the redirects
  • Update https.rs::selected_target_and_proxy to apply redirection if needed
  • Update README.md
  • Test
  • Deploy on staging
    • build: nix build
    • sign: nix store sign --key-file <(pass deuxfleurs/nix_priv_key) $(nix build)
    • Push on nix.web.deuxfleurs.fr
      • source ~/.awsrc
      • nix copy --to 's3://nix?endpoint=garage.deuxfleurs.fr&region=garage' $(nix build)
    • Edit Nomad HCL
      • 28: packages = [ "git+https://git.deuxfleurs.fr/Deuxfleurs/tricot.git?ref=redirect&rev=b76b6dcbcc47ebc61848389a6b0d5d4e8d8cde48" ]
    • Check how it behaves
  • Deploy on prod
    • docker build -t "superboum/amd64_tricot:52" . (prev was: lxpz/amd64_tricot:51)
    • docker push superboum/tricot_amd64:52
    • Edit Nomad HCL
    • Check how it behaves
    • Add redirect 301 for www.deuxfleurs.fr -> deuxfleurs.fr
    • Add redirect 301 for osuny.org -> www.osuny.org
    • Others?

Note: we should really build tricot docker containers with nix...

Test

python3 -m http.server 
consul services register \
  -name test \
  -address=localhost \
  -port 8000 \
  -tag="tricot a.localhost" \
  -tag="tricot b.localhost" \
  -tag "tricot c.localhost" \
  -tag "tricot-add-redirect b.localhost a.localhost 302" \
  -tag "tricot-add-redirect c.localhost/x a.localhost/y 301"
$ curl -I -k https://a.localhost/
HTTP/2 200
server: SimpleHTTP/0.6 Python/3.10.13
date: Wed, 29 Nov 2023 15:10:14 GMT
content-type: text/html; charset=utf-8
content-length: 729

$ curl -I -k https://b.localhost/
HTTP/2 302
location: https://a.localhost/
date: Wed, 29 Nov 2023 15:10:24 GMT
content-length: 20

$ curl -I -k https://b.localhost/about/index.html
HTTP/2 302
location: https://a.localhost/about/index.html
date: Wed, 29 Nov 2023 15:10:36 GMT
content-length: 36

$ curl -I -k https://c.localhost/x/aaaa
HTTP/2 301
location: https://a.localhost/y/aaaa
date: Wed, 29 Nov 2023 15:09:58 GMT
content-length: 26

$ curl -I -k https://c.localhost
HTTP/2 200
server: SimpleHTTP/0.6 Python/3.10.13
date: Wed, 29 Nov 2023 15:11:09 GMT
content-type: text/html; charset=utf-8
content-length: 729

Limitations

  • Query parameters are not supported (a.example.com/a?x=y is redirected to b.example.com/b)
  • Relative destination redirect is not supported (a target that keeps the original host but only change the path)
  • Large number of redirects are not supported (we have a O(n) complexity in term of redirections)
## Roadmap - [x] Update `proxy_config.rs` to fetch the redirects - [x] Update `https.rs::selected_target_and_proxy` to apply redirection if needed - [x] Update README.md - [x] Test - [x] Deploy on staging - [X] build: `nix build` - [x] sign: `nix store sign --key-file <(pass deuxfleurs/nix_priv_key) $(nix build)` - [x] Push on nix.web.deuxfleurs.fr - `source ~/.awsrc` - `nix copy --to 's3://nix?endpoint=garage.deuxfleurs.fr&region=garage' $(nix build)` - [x] Edit Nomad HCL - `28: packages = [ "git+https://git.deuxfleurs.fr/Deuxfleurs/tricot.git?ref=redirect&rev=b76b6dcbcc47ebc61848389a6b0d5d4e8d8cde48" ]` - [x] Check how it behaves - [x] Deploy on prod - [x] `docker build -t "superboum/amd64_tricot:52" .` (prev was: `lxpz/amd64_tricot:51`) - [x] `docker push superboum/tricot_amd64:52 ` - [x] Edit Nomad HCL - [x] Check how it behaves - [x] Add redirect 301 for www.deuxfleurs.fr -> deuxfleurs.fr - [x] Add redirect 301 for osuny.org -> www.osuny.org - [x] Others? *Note: we should really build tricot docker containers with nix...* ## Test ```bash python3 -m http.server consul services register \ -name test \ -address=localhost \ -port 8000 \ -tag="tricot a.localhost" \ -tag="tricot b.localhost" \ -tag "tricot c.localhost" \ -tag "tricot-add-redirect b.localhost a.localhost 302" \ -tag "tricot-add-redirect c.localhost/x a.localhost/y 301" ``` ``` $ curl -I -k https://a.localhost/ HTTP/2 200 server: SimpleHTTP/0.6 Python/3.10.13 date: Wed, 29 Nov 2023 15:10:14 GMT content-type: text/html; charset=utf-8 content-length: 729 $ curl -I -k https://b.localhost/ HTTP/2 302 location: https://a.localhost/ date: Wed, 29 Nov 2023 15:10:24 GMT content-length: 20 $ curl -I -k https://b.localhost/about/index.html HTTP/2 302 location: https://a.localhost/about/index.html date: Wed, 29 Nov 2023 15:10:36 GMT content-length: 36 $ curl -I -k https://c.localhost/x/aaaa HTTP/2 301 location: https://a.localhost/y/aaaa date: Wed, 29 Nov 2023 15:09:58 GMT content-length: 26 $ curl -I -k https://c.localhost HTTP/2 200 server: SimpleHTTP/0.6 Python/3.10.13 date: Wed, 29 Nov 2023 15:11:09 GMT content-type: text/html; charset=utf-8 content-length: 729 ``` ## Limitations - Query parameters are not supported (`a.example.com/a?x=y` is redirected to `b.example.com/b`) - Relative destination redirect is not supported (a target that keeps the original host but only change the path) - Large number of redirects are not supported (we have a O(n) complexity in term of redirections)
quentin added 1 commit 2023-11-29 11:53:22 +00:00
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is failing Details
de72d6037f
refactor configuration to support redirects
quentin added 1 commit 2023-11-29 12:06:39 +00:00
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
f11592926b
fix tests
quentin added 1 commit 2023-11-29 14:50:36 +00:00
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
2b3f934247
implement redirection in https.rs
quentin changed title from WIP: New directive `tricot-add-redirect <match-prefix> <redirect-prefix> [301|302]` to WIP: New directive `tricot-add-redirect <match-prefix> <redirect-prefix> [301|302|303|307]` 2023-11-29 15:14:00 +00:00
quentin added 1 commit 2023-11-29 15:17:55 +00:00
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
b76b6dcbcc
add tricot-add-redirect in readme
quentin changed title from WIP: New directive `tricot-add-redirect <match-prefix> <redirect-prefix> [301|302|303|307]` to New directive `tricot-add-redirect <match-prefix> <redirect-prefix> [301|302|303|307]` 2023-11-29 15:18:22 +00:00
quentin merged commit b04c2bfb0a into main 2023-11-29 16:09:56 +00:00
quentin deleted branch redirect 2023-11-29 16:09:56 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 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/tricot#10
No description provided.