Giter Site home page Giter Site logo

haproxy's Introduction

haproxy

###Installation

Install Lua

Install haproxy

  • git clone http://git.haproxy.org/git/haproxy-1.6.git/
  • cd haproxy-1.6
  • On macosx change --export-dynamic to -export_dynamic in Makefile
  • make TARGET=generic USE_DL=1 USE_LUA=1 USE_OPENSSL=1 SSL_LIB=/path/to/openssl/lib SSL_INC=/path/to/openssl/include LUA_LIB=/path/to/lua/lua-5.3.1_install/lib LUA_INC=/path/to/lua/lua-5.3.1_install/include
  • mkdir ../haproxy-1.6_install
  • make PREFIX=/path/to/haproxy/haproxy-1.6_install install

Running haproxy frontend lua

  • cd ../haproxy-1.6_install/
  • create a file called hello_world.lua
core.register_service("hello-world", "http", function(applet)
        local response = "Hello World !"
        applet:set_status(200)
        applet:add_header("content-length", string.len(response))
        applet:add_header("content-type", "text/plain")
        applet:start_response()
        applet:send(response)
    end)
  • create the config file hello_world.cfg
global
       lua-load hello_world.lua

        defaults
            mode http
            timeout connect 5000ms
            timeout client 50000ms
            timeout server 50000ms

        frontend example
            bind 127.0.0.1:10001
            http-request use-service lua.hello-world


        listen stats
            # Uncomment "disabeled" below to disable the stats page :
            # disabled
            bind       :8888
            stats uri /
  • Check if config is valid
sbin/haproxy -f hello_world.cfg -c
  • run haproxy and curl
sbin/haproxy -f hello_world.cfg
curl -v 127.0.0.1:10001
  • Check stats
http://127.0.0.1:8888/

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.