Mod Wombat

lua-users home
wiki

ModWombat is an Apache module which allows you to script webpages in Lua. It only works with Apache 2.3+ (there are plans to release it with Apache 2.4 under the name of mod_lua [1]) and has a number of options available for reusing LuaStates?, caching compiled scripts, etc.

Following are some thoughts on improvements which could/should be made to mod_wombat. These ideas are from Brian Akins.

// Ability for other modules to call lua without worrying about caching,
// compiling, etc.  i.e. something like:
APR_DECLARE_OPTIONAL_FN(apr_status_t, lua_request_register, (apr_pool_t
*pool, lua_request_t **new, const char *file));
APR_DECLARE_OPTIONAL_FN(apr_status_t, lua_request_run, (request_rec * r,
lua_request_t *run, const char *function, apr_status_t *rc));

In theory, this generalized "framework" would be used by mod_wombat internally.

-Per thread vm's. An httpd thread has a dedicated lua vm for each file.

(We do these two things^^. Brian M. has our very hacked version of mod_wombat. I can post it here if there is interest)

Support for in httpd.conf Lua. Ie, I want to be able to do "simple" lua in the config rather than having to use a separate file.

<Lua my_cool_code>
require 'string'
require 'apache2'
function simple_redirect(r)
    if string.match(r.headers_in['User-Agent'], 'mozilla') then
        r.headers_out['Location'] = 'http://somecoolmozillasite.com/stuff'
        return apache2.HTTP_MOVED_TEMPORARILY
    end 
end
</Lua>

<Location /my_ie_only_app>
   LuaHook fixups my_cool_code:simple_redirect
</Location>

(Bad example, but you get the general idea)

Ability to make "real" modules in Lua:

function register_hooks(p)
    apache2.hook_handler(my_handler, NULL, NULL, apache2.HOOK_MIDDLE)
end

apache2.module(
    apache2.STANDARD20_MODULE_STUFF,
    create_dir_cfg,
    merge_dir_cfg,
    create_svr_cfg,
    merge_svr_cfg,
    cmd_table,
    register_hooks
)

The modules loading is place I see this being tricky.

For the truly ambitious, I'd like to be able to configure apache via lua:

httpd.load_module('mime_module', 'modules/mod_mime.so')
v = apache2.server.new()
v:document_root = '/opt/apache/htdocs'
mod_mime:types_config = '/etc/mime.types'
mod_env.set_env('X-Lua', 'is cool')

Not valid, but something like that...


RecentChanges · preferences
edit · history
Last edited May 18, 2009 1:37 am GMT (diff)