mod_mruby is to provide an alternative to mod_lua.
- Apache modules can be implemeted by mruby scripts on Apache HTTP Server installed mod_mruby.
- Supported Apache Version: 2.0 2.2 2.4 2.5
- Supported Apache MPM: worker prefork event
- Supported OS: Linux FreeBSD Windows and so on.
git clone git://github.com/matsumoto-r/mod_mruby.git
cd mod_mruby
sh build.sh
-
Add to httpd.conf
LoadModule mruby_module modules/mod_mruby.so AddHandler mruby-script .rb
-
test.rb copy
cp -p test/test.rb $(APACHE_DOCMENT_ROOT)/.
service httpd restart
curl http://127.0.0.1/test.rb
-
mruby/mruby build
cd mod_mruby git submodule init git submodule update cd mruby rake cd ..
-
configure
./configure
-
using mruby/mruby
make make install
- Selecting vhost area like mod_vhost_alias(hook on translatename)
r = Apache::Request.new() s = Apache::Server.new() r.filename = s.document_root + "/" + r.hostname + "/" + r.uri Apache::return(Apache::OK)
- Proxy balancer like mod_proxy_balancer(hook on translatename)
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)
under the MIT License: