[packages] add HAProxy, a high performance HTTP/TCP reverse proxy and load balancer - thanks Thomas Heil <heil@terminal-consulting.de>
git-svn-id: svn://svn.openwrt.org/openwrt/packages@18880 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
1f9c06385f
commit
f0b48001e1
55
net/haproxy/Makefile
Normal file
55
net/haproxy/Makefile
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2009 Thomas Heil <heil@terminal-consulting.de>
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=haproxy
|
||||||
|
PKG_VERSION:=1.3.22
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=http://haproxy.1wt.eu/download/1.3/src/
|
||||||
|
PKG_MD5SUM:=b84e0935cfea99eda43645d53bb82367
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/haproxy
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
DEPENDS:=+libpcre +libltdl
|
||||||
|
TITLE:=The Reliable, High Performance TCP/HTTP Load Balancer
|
||||||
|
URL:=http://haproxy.1wt.eu/
|
||||||
|
SUBMENU:=Proxy Servers
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/haproxy/conffiles
|
||||||
|
/etc/haproxy.cfg
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/haproxy/description
|
||||||
|
Open source High Performance TCP/HTTP Load Balancer
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(MAKE) TARGET=$(if $(CONFIG_LINUX_2_4),linux24,linux26) -C $(PKG_BUILD_DIR) \
|
||||||
|
DESTDIR="$(PKG_INSTALL_DIR)" \
|
||||||
|
CC="$(TARGET_CC)" \
|
||||||
|
CFLAGS="$(TARGET_CFLAGS)" \
|
||||||
|
LD="$(TARGET_CC)" \
|
||||||
|
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||||
|
all install
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/haproxy/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/sbin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/haproxy $(1)/usr/sbin/
|
||||||
|
$(INSTALL_DIR) $(1)/etc
|
||||||
|
$(INSTALL_CONF) ./files/haproxy.cfg $(1)/etc/
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) ./files/haproxy.init $(1)/etc/init.d/haproxy
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,haproxy))
|
96
net/haproxy/files/haproxy.cfg
Normal file
96
net/haproxy/files/haproxy.cfg
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# Example configuration file for HAProxy 1.3, refer to the url below for
|
||||||
|
# a full documentation and examples for configuration:
|
||||||
|
# http://haproxy.1wt.eu/download/1.3/doc/configuration.txt
|
||||||
|
|
||||||
|
|
||||||
|
# Global parameters
|
||||||
|
global
|
||||||
|
|
||||||
|
# Log events to a remote syslog server at given address using the
|
||||||
|
# specified facility and verbosity level. Multiple log options
|
||||||
|
# are allowed.
|
||||||
|
#log 10.0.0.1 daemon info
|
||||||
|
|
||||||
|
# Specifiy the maximum number of allowed connections.
|
||||||
|
maxconn 32000
|
||||||
|
|
||||||
|
# Raise the ulimit for the maximum allowed number of open socket
|
||||||
|
# descriptors per process. This is usually at least twice the
|
||||||
|
# number of allowed connections (maxconn * 2 + nb_servers + 1) .
|
||||||
|
ulimit-n 65535
|
||||||
|
|
||||||
|
# Drop privileges (setuid, setgid), default is "root" on OpenWrt.
|
||||||
|
uid 0
|
||||||
|
gid 0
|
||||||
|
|
||||||
|
# Perform chroot into the specified directory.
|
||||||
|
#chroot /var/run/haproxy/
|
||||||
|
|
||||||
|
# Daemonize on startup
|
||||||
|
daemon
|
||||||
|
|
||||||
|
# Enable debugging
|
||||||
|
#debug
|
||||||
|
|
||||||
|
# Spawn given number of processes and distribute load among them,
|
||||||
|
# used for multi-core environments or to circumvent per-process
|
||||||
|
# limits like number of open file descriptors. Default is 1.
|
||||||
|
#nbproc 2
|
||||||
|
|
||||||
|
|
||||||
|
# Example HTTP proxy listener
|
||||||
|
listen my_http_proxy
|
||||||
|
|
||||||
|
# Bind to port 80 and 443 on all interfaces (0.0.0.0)
|
||||||
|
bind :80,:443
|
||||||
|
|
||||||
|
# We're proxying HTTP here...
|
||||||
|
mode http
|
||||||
|
|
||||||
|
# Simple HTTP round robin over two servers using the specified
|
||||||
|
# source ip 192.168.1.1 .
|
||||||
|
balance roundrobin
|
||||||
|
server server01 192.168.1.10:80 source 192.168.1.1
|
||||||
|
server server02 192.168.1.20:80 source 192.168.1.1
|
||||||
|
|
||||||
|
# Serve an internal statistics page on /stats:
|
||||||
|
stats enable
|
||||||
|
stats uri /stats
|
||||||
|
|
||||||
|
# Enable HTTP basic auth for the statistics:
|
||||||
|
stats realm HA_Stats
|
||||||
|
stats auth username:password
|
||||||
|
|
||||||
|
|
||||||
|
# Example SMTP proxy listener
|
||||||
|
listen my_smtp_proxy
|
||||||
|
|
||||||
|
# Disable this instance without commenting out the section.
|
||||||
|
disable
|
||||||
|
|
||||||
|
# Bind to port 25 and 587 on localhost
|
||||||
|
bind 127.0.0.1:25,127.0.0.1:587
|
||||||
|
|
||||||
|
# This is a TCP proxy
|
||||||
|
mode tcp
|
||||||
|
|
||||||
|
# Round robin load balancing over two servers on port 123 forcing
|
||||||
|
# the address 192.168.1.1 and port 25 as source.
|
||||||
|
balance roundrobin
|
||||||
|
server server01 192.168.1.10:123 source 192.168.1.1:25
|
||||||
|
server server02 192.168.1.20:123 source 192.168.1.1:25
|
||||||
|
|
||||||
|
|
||||||
|
# Special health check listener for integration with external load
|
||||||
|
# balancers.
|
||||||
|
listen local_health_check
|
||||||
|
|
||||||
|
# Listen on port 60000
|
||||||
|
bind :60000
|
||||||
|
|
||||||
|
# This is a health check
|
||||||
|
mode health
|
||||||
|
|
||||||
|
# Enable HTTP-style responses: "HTTP/1.0 200 OK"
|
||||||
|
# else just print "OK".
|
||||||
|
#option httpchk
|
26
net/haproxy/files/haproxy.init
Normal file
26
net/haproxy/files/haproxy.init
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Copyright (C) 2009 OpenWrt.org
|
||||||
|
|
||||||
|
START=99
|
||||||
|
STOP=80
|
||||||
|
|
||||||
|
HAPROXY_BIN="/usr/sbin/haproxy"
|
||||||
|
HAPROXY_CONFIG="/etc/haproxy.cfg"
|
||||||
|
HAPROXY_PID="/var/run/haproxy.pid"
|
||||||
|
|
||||||
|
start() {
|
||||||
|
[ -x "$HAPROXY_BIN" ] || return 1
|
||||||
|
|
||||||
|
start-stop-daemon -S -x $HAPROXY_BIN -- \
|
||||||
|
-f "$HAPROXY_CONFIG" -V -D -d -p "$HAPROXY_PID"
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
start-stop-daemon -K -x $HAPROXY_BIN -p $HAPROXY_PID
|
||||||
|
rm -f $HAPROXY_PID
|
||||||
|
}
|
||||||
|
|
||||||
|
reload() {
|
||||||
|
[ ! -f "$HAPROXY_PID" ] && start
|
||||||
|
$HAPROXY_BIN -f $HAPROXY_CONFIG -p $HAPROXY_PID -st $(cat $HAPROXY_PID)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user