Coder Social home page Coder Social logo

mod_mruby's Introduction

Welcome to the mod_mruby wiki!

What's mod_mruby

mod_mruby - to provide an alternative to mod_lua.

Apache modules can be implemeted by mruby scripts on Apache HTTP Server 2.2/2.4 installed mod_mruby.

How to use

1. Download

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

2. Compile

  • using mruby/murby

      make
    
  • using iij/mruby

      make extend
    

3. Install

make install

4. Settings

  • 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
      

5. Apache Restart

/etc/init.d/httpd restart

6. Install Test

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.