Skip to content

Instantly share code, notes, and snippets.

@julik
Created November 14, 2009 11:11
Show Gist options
  • Save julik/234480 to your computer and use it in GitHub Desktop.
Save julik/234480 to your computer and use it in GitHub Desktop.
# Lighttpd sets the wrong SCRIPT_NAME and PATH_INFO if you mount your
# FastCGI app at "/". This middleware fixes this issue. This is also
# modified to account for the case when SCRIPT_NAME is the name of the
# 404 script
class LightyWorkaround
def initialize(app)
@app = app
end
def call(env)
uri, qs = env["REQUEST_URI"].to_s.split('?')
@app.call(env.merge("PATH_INFO" => uri, "QUERY_STRING" => (qs || ''), "SCRIPT_NAME" => ""))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment