> Dnia wtorek, 20 grudnia 2011 19:47:59 Roberto De Ioris pisze:
>> > Great, the only thing I'm missing from uWSGI is possibility to:
>> > * write redirect/rewrite rules in vassal config
>>
>> i need this too for my company, but i am quite unsure un how to realize
>> that.
>>
>> My first idea was having a "router" request plugin, that you can map to
>> a
>> bunch of code
>> in one of the supported languages, used as a "filter" for the request:
>>
>> #in perl
>>
>> sub my_uwsgi_router {
>> [...]
>> }
>>
>> the "bad" thing is that for a simple "rewrite rule" you need to manage
>> PATH_INFO,REQUEST_URI,QUERY_STRING and SCRIPT_NAME (at least) but maybe
>> this is not a real problem but a feature :)
>
> At first I didn't understand why You need to do all the above, but then I
> realized that vassal doesn't get HTTP requests, it gets uwsgi protocol
> requests, so it's maybe not as simple as putting:
> redirect = / /my/page/index
> rewrite = ^.+$ %{PATH_INFO}.php
> into vassal config.
> Adding any advanced login into configuration may be more problematic than
> parsing requests as You would need a config syntax that is
> a) powerfull enough to handle everything user may want to setup (look how
> easy
>



I am pretty sure i will end with a --filter option:

[uwsgi]
...

filter = /var/www/defaultfilter.lua
filter = myfilter.lua
filter = myfilter.pl

This will means:

At each request apply the filter /var/www/defaultfilter.lua (if exists)
then myfilter.lua (if exists) then myfilter.pl (if exists).

A filter is a function in a language of choice:

function filter(modifier1, modifier2, env)
  if string.find(env['PATH_INFO'], '.php') then
    return { 14, 0, env}
  end
  return { 0,0, env}
end

this means, rewrite the request to use modifier 14 if PATH_INFO contains .php


The advantage in this approach is that you can define a "generic" rule
(like /var/www/defaultfilter.lua) and then each of your vassal can choose
to attach a filter simply creating a file with the specified name. They
remove the file when they do not need the filter anymore. All without
restarting uWSGI.


>> The "--static-index" would be required in your case.
>
> I see that static-index was added to 1.0 so I've added:
> static-index = index.html
> to my vassal config and it works as expected, but I'm not sure what value
> does
> this option expects as index=1 also works and show /index.html if I
> request /
> path.


The argument is the name of the file, maybe it works beacause your nginx
is already using an index directive so the PATH_INFO will come directly as
/index.html in uWSGI.

-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to