Plack:...ocation(3pm)

πŸ“¦
version 0.29 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– Plack::Middleware::Proxy::RewriteLocation πŸ’–

okay bestie, welcome to the User Contributed Perl Documentation, section 3pm β€” this is the page for Plack::Middleware::Proxy::RewriteLocation and honestly? it's giving quiet overachiever. she's small, she's focused, she rewrites redirect headers. periodt.


✨ NAME ✨

Plack::Middleware::Proxy::RewriteLocation β€” rewrites redirect headers πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

okay so first, the classic setup. mount it, enable it, boom:

use Plack::Builder;
use Plack::App::Proxy;

builder {
    enable "Proxy::RewriteLocation";
    Plack::App::Proxy->new(remote => "http://10.0.1.2:8080/")->to_app;
};

and or, if you're mounting (i.e. URLMap-ing, bestie) the proxied site at /foo:

builder {
    enable "Proxy::RewriteLocation", url_map => [ '/foo' => http://10.0.1.2:8080' ];
    mount '/foo' => Plack::App::Proxy->new(remote => "http://10.0.1.2:8080/")->to_app;
};
🫢 ngl the ### comments in the original? iconic. the http://10.0.1.2:8080' in that second block is written exactly like that in the source, so I'm keeping it exactly like that. no cap, no fixing, that's the rule.

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does she actually do?

Plack::Middleware::Proxy::RewriteLocation rewrites the Location header in the response when the remote host redirects using its own headers. it's literally the Plack version of mod_proxy's ProxyPassReverse option. that's the whole vibe. redirect comes back pointing at the remote, she's like "not on my watch πŸ’…" and rewrites it so your users stay where they're supposed to be.


🌸 OPTIONS 🌸

just one, and she's a queen:

  • url_map (arrayref) β€” if you give this, it will account for mounted (URLMapped) Proxy apps when rewriting Location headers. it gets applied in order, and it stops at the first successful match with the remote Location. so like, order matters, bestie. first match wins, that's it.

πŸ‘‘ AUTHOR πŸ‘‘

Tatsuhiko Miyagawa Robert Buels

🫢 the whole squad, together, on one line. we love to see it.

πŸ”₯ SEE ALSO πŸ”₯

  • Plack::App::Proxy

and that's the page, fr fr. πŸ’– this one's from perl v5.32.0, dated 2021-01-09, and the manual name on the tin is Plack:...ocation(3pm) (yes, truncated exactly like that, she's mysterious like that 😭). slay, go rewrite some Locations, bestie. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from