Lighttpd: how to rewrite the URI before passing to uwsgi?

36 Views Asked by At

I have a wsgi app running under Lighttpd. The entire API is registered under /forms but that's a local configuration.

server.modules += ( "mod_scgi" )
scgi.debug = 7
$HTTP["url"] =~ "^/forms" {
    scgi.protocol = "uwsgi"
    scgi.server   = ( "/" => 
        ((
            "host" => "localhost",
            "port" => 8000,
            "fix-root-scriptname" => "enable",
            "check-local" => "disable",    
        ))
    )
}

My goal is to NOT make uwsgi aware of the /forms prefix, ie it should be agnostic regarding the global configuration so I can change it without changing the code.

For example, as a toy handler I would have to write this:

@app.route('/forms')
def index():
    return "<span style='color:red'>I am app 1</span>"

But if I later change the the lighttpd.conf setting, I would have also to setup the uwsgi accordingly, which I don't want to.

However mod_rewrite does not work inside the $HTTP["url"] section so I am at a loss of how to accomplish that.

Ideally I would not like to change uwsgi.ini as well. Ideas?

0

There are 0 best solutions below