-
Notifications
You must be signed in to change notification settings - Fork 30
Home
matsumoto-r edited this page Jul 6, 2012
·
61 revisions
mod_mruby - to provide an alternative to mod_lua.
Apache modules can be implemeted by mruby scripts on Apache HTTP Server installed mod_mruby.
make
make install
-
Add to /usr/local/apache/conf/httpd.conf
LoadModule mruby_module modules/mod_mruby.so # remove comment out if you use .mrb as Web contens # AddHandler mruby-script .mrb-
hook mrb-script on ap_hook_translateName Middle phase
mrubyTranslateNameMiddle /path/to/file.mrb
-
/etc/init.d/httpd restart
- Selecting vhost area like mod_vhost_alias
r = Apache::Request.new() s = Apache::Server.new() r.filename = s.docroot + "/" + r.hostname + "/" + r.uri Apache::return(Apache::OK)
- Proxy balancer like mod_proxy_balancer
backends = [ "http://192.168.0.101:8888/", "http://192.168.0.102:8888/", "http://192.168.0.103:8888/", "http://192.168.0.104:8888/", ] # write balancing algorithm here. r = Apache::Request.new() r.handler = "proxy-server" r.proxyreq = Apache::PROXYREQ_REVERSE r.filename = "proxy:" + backends[rand(backends.length)] + r.uri Apache::return(Apache::OK)