[uWSGI] Rewrite routing problem
Roberto De Ioris
roberto at unbit.it
Sat Mar 16 18:09:50 CET 2013
> * Roberto De Ioris <roberto-5KDOxZqKugI at public.gmane.org> [2013-03-16
>>> I've a problem getting rewriting via router_rewrite to work, the
>>> following rewrite rule does not seem to do anything:
>>> $ ./uwsgi
>>> --http-socket=:8080 --check-static=$PWD --route-uri='^/logo$
>>> $ curl -I http://127.0.0.1:8080/logo
>>> HTTP/1.1 404 Not Found
>>> Connection: close
>>> Content-Type: text/plain
>>> $ curl -I http://127.0.0.1:8080/logo_uWSGI.png
>>> HTTP/1.1 200 OK
>>> Content-Type: image/png
>>> Content-Length: 5971
>>> Last-Modified: Sun, 10 Mar 2013 21:24:48 GMT
>>> Am I doing something wrong or is this a bug? This isn't related
>>> to bug #183, it happens before the fix as well.
>>> Guido Berhoerster
>> Check-static happens before routing. What you "rewrite" are the CGI vars
>> (PATH_INFO and QUERY_STRING) passed to the plugin.
> Ok, that makes sense, my expectations are still heavily
> influenced by mod_rewrite and nginx's httprewrite module.
>> Hint: are you sure you do not need a "static" plugin like the 404 one ?
> I suppose, together with autoindex functionality it could
> probably completely replace the need for a webserver like nginx,
> lighttpd, or apache. But currently no such thing exists, right?
I think you will be able to write it (based on the notfound and
router_static) in no more than 20 lines :)
After having parsed the request (uwsgi_parse_vars(), line in "notfound")
you only need to call:
uwsgi_file_serve(wsgi_req, docroot, docroot_len, path_info, path_info_len,
(is_a_file force the function to consider path_info as a full filename as
we do in router_static, ignoring the document root)
You do not need to bother about performance or security, your plugin can
focus on generation fo document_roots and filenames
Roberto De Ioris
More information about the uWSGI