Plack::...NameFix(3)

πŸ’– NAME πŸ’–

okay bestie, gather round: this is the Plack::...NameFix(3) page, and it's all about Plack::Middleware::LighttpdScriptNameFix β€” the middleware that fixes the wrong SCRIPT_NAME and PATH_INFO that lighttpd sets 🫢


✨ SYNOPSIS ✨

drop it into your app like this:

# in your app.psgi
use Plack::Builder;

builder {
  enable "LighttpdScriptNameFix";
  $app;
};

or if you're a command-line girlie, do it like this instead:

# Or from the command line
plackup -s FCGI -e 'enable "LighttpdScriptNameFix"' /path/to/app.psgi

🌸 DESCRIPTION 🌸

so here's the tea πŸ“ β€” lighttpd be out here setting SCRIPT_NAME and PATH_INFO all wrong when you mount your app under the root path ("/"). this middleware swoops in and fixes it, iconic behavior honestly.

but wait β€” if you're on lighttpd 1.4.23 or later, you don't even need this middleware, because you can just enable the fix-root-scriptname flag inside fastcgi.server instead. slay, options πŸ’…


πŸŽ€ CONFIGURATION πŸŽ€

πŸ’œ script_name

ngl, even with fix-root-scriptname, lighttpd still goes ahead and sets weird SCRIPT_NAME and PATH_INFO if you mount your application at "" or at something that ends with "/". so rude of it 😭

setting the script_name option tells the middleware how to reconstruct the new correct SCRIPT_NAME and PATH_INFO. basically you're handing it the map πŸ—ΊοΈ

if you mount the app under "/something/", you should set:

enable "LighttpdScriptNameFix", script_name => "/something";

and then when a request for "/something/a/b?param=1" comes rolling in, SCRIPT_NAME becomes "/something" and PATH_INFO becomes "/a/b". no cap, that's the glow-up ✨

the script_name option is set to empty by default, which means all the request path gets set to PATH_INFO, and it behaves like your fastcgi application is mounted in the root path. periodt πŸ’«


πŸ‘‘ AUTHORS πŸ‘‘

  • Yury Zavarin
  • Tatsuhiko Miyagawa

absolute legends, fr fr 🫑


🌈 SEE ALSO 🌈


lowkey a warning that's just a vibe check: the weird "" / trailing-"/" mount behavior is real, and the default empty script_name really does mean everything lands in PATH_INFO like your app lives at the root. don't @ me, that's just what the docs say 🧚

and that's the whole page babes πŸ’– this one shipped as perl v5.42.3 on 2026-10-18 β€” go forth and fix those script names, main character energy only πŸ”₯

πŸ“¦ where this page comes from