Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
mod_mruby - A Fast and Memory-Efficient Web Server Extension Mechanism Using Scripting Language mruby for Apache httpd

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
lib
mruby @ d8c4f6a
test
webif
.gitignore
.gitmodules
AUTHORS
Makefile.in
Makefile.w32
README.md
TODO
ap_mrb_authnprovider.c
ap_mrb_authnprovider.h
ap_mrb_connection.c
ap_mrb_connection.h
ap_mrb_env.c
ap_mrb_env.h
ap_mrb_filter.c
ap_mrb_filter.h
ap_mrb_init.c
ap_mrb_init.h
ap_mrb_request.c
ap_mrb_request.h
ap_mrb_scoreboard.c
ap_mrb_scoreboard.h
ap_mrb_server.c
ap_mrb_server.h
ap_mrb_utils.c
ap_mrb_utils.h
build.sh
build_config.rb
config.h.in
configure
configure.in
mod_mruby.c
mod_mruby.h

README.md

Welcome to the mod_mruby wiki!

What's mod_mruby

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.

How to use

1. Download

git clone git://github.com/matsumoto-r/mod_mruby.git

2. Auto Build

cd mod_mruby
sh build.sh

3. Test Settings

  • 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)/.
    

4. Apache Restart

service httpd restart

5. Access URL by Browser

curl http://127.0.0.1/test.rb

Manual Build

  • mruby/mruby build

    cd mod_mruby
    git submodule init
    git submodule update
    cd mruby
    rake
    cd ..
    
  • configure

    ./configure
    
  • using mruby/mruby

    make
    make install
    

Example

  • 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)

Functions

Data Structure

License

under the MIT License:

Something went wrong with that request. Please try again.