diff --git a/packages/haproxy/Makefile.patch b/packages/haproxy/Makefile.patch new file mode 100644 index 000000000..00a873152 --- /dev/null +++ b/packages/haproxy/Makefile.patch @@ -0,0 +1,26 @@ +diff -uNr haproxy-2.3.1/Makefile haproxy-2.3.1.mod/Makefile +--- haproxy-2.3.1/Makefile 2020-11-13 20:20:03.000000000 +0000 ++++ haproxy-2.3.1.mod/Makefile 2020-11-23 13:37:28.797578825 +0000 +@@ -134,10 +134,10 @@ + + #### Installation options. + DESTDIR = +-PREFIX = /usr/local +-SBINDIR = $(PREFIX)/sbin ++PREFIX ?= /usr/local ++SBINDIR = $(PREFIX)/bin + MANDIR = $(PREFIX)/share/man +-DOCDIR = $(PREFIX)/doc/haproxy ++DOCDIR = $(PREFIX)/share/doc/haproxy + + #### TARGET system + # Use TARGET= to optimize for a specific target OS among the +@@ -161,7 +161,7 @@ + ARCH = + + #### Toolchain options. +-CC = cc ++CC ?= cc + LD = $(CC) + + #### Debug flags (typically "-g"). diff --git a/packages/haproxy/build.sh b/packages/haproxy/build.sh new file mode 100644 index 000000000..77def201a --- /dev/null +++ b/packages/haproxy/build.sh @@ -0,0 +1,45 @@ +TERMUX_PKG_HOMEPAGE=https://www.haproxy.org/ +TERMUX_PKG_DESCRIPTION="The Reliable, High Performance TCP/HTTP Load Balancer" +TERMUX_PKG_LICENSE="GPL-2.0" +TERMUX_PKG_MAINTAINER="Leonid Pliushch " +TERMUX_PKG_VERSION=2.4.2 +TERMUX_PKG_REVISION=1 +TERMUX_PKG_SRCURL=http://www.haproxy.org/download/${TERMUX_PKG_VERSION:0:3}/src/haproxy-${TERMUX_PKG_VERSION}.tar.gz +TERMUX_PKG_SHA256=edf9788f7f3411498e3d7b21777036b4dc14183e95c8e2ce7577baa0ea4ea2aa +TERMUX_PKG_DEPENDS="liblua53, openssl, pcre, zlib" +TERMUX_PKG_BUILD_IN_SRC=true + +TERMUX_PKG_CONFFILES="etc/haproxy/haproxy.cfg" + +termux_step_make() { + CC="$CC -Wl,-rpath=$TERMUX_PREFIX/lib -Wl,--enable-new-dtags" + + make \ + CPU=generic \ + TARGET=generic \ + USE_GETADDRINFO=1 \ + USE_LUA=1 \ + LUA_INC="$TERMUX_PREFIX/include/lua5.3" \ + LUA_LIB="$TERMUX_PREFIX/lib" + LUA_LIB_NAME=lua5.3 \ + USE_OPENSSL=1 \ + USE_PCRE=1 \ + PCRE_INC="$TERMUX_PREFIX/include" \ + PCRE_LIB="$TERMUX_PREFIX/lib" \ + USE_ZLIB=1 \ + ADDINC="$CPPFLAGS" \ + CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" +} + +termux_step_post_make_install() { + mkdir -p "$TERMUX_PREFIX"/etc/haproxy + sed -e "s|@TERMUX_PREFIX@|${TERMUX_PREFIX}|g" \ + "$TERMUX_PKG_BUILDER_DIR"/haproxy.cfg.in \ + > "$TERMUX_PREFIX"/etc/haproxy/haproxy.cfg + + mkdir -p "$TERMUX_PREFIX"/share/haproxy/examples/errorfiles + install -m600 examples/*.cfg "$TERMUX_PREFIX"/share/haproxy/examples/ + install -m600 examples/errorfiles/*.http \ + "$TERMUX_PREFIX"/share/haproxy/examples/errorfiles/ +} diff --git a/packages/haproxy/haproxy.cfg.in b/packages/haproxy/haproxy.cfg.in new file mode 100644 index 000000000..2ea5b972a --- /dev/null +++ b/packages/haproxy/haproxy.cfg.in @@ -0,0 +1,47 @@ +#--------------------------------------------------------------------- +# Example configuration. See the full configuration manual online. +# +# http://www.haproxy.org/download/1.7/doc/configuration.txt +# +#--------------------------------------------------------------------- + +global + maxconn 20000 + log 127.0.0.1 local0 + pidfile @TERMUX_PREFIX@/var/run/haproxy.pid + daemon + +frontend main + bind :5000 + mode http + log global + option httplog + option dontlognull + option http_proxy + option forwardfor except 127.0.0.0/8 + maxconn 8000 + timeout client 30s + + acl url_static path_beg -i /static /images /javascript /stylesheets + acl url_static path_end -i .jpg .gif .png .css .js + + use_backend static if url_static + default_backend app + +backend static + mode http + balance roundrobin + timeout connect 5s + timeout server 5s + server static 127.0.0.1:4331 check + +backend app + mode http + balance roundrobin + timeout connect 5s + timeout server 30s + timeout queue 30s + server app1 127.0.0.1:5001 check + server app2 127.0.0.1:5002 check + server app3 127.0.0.1:5003 check + server app4 127.0.0.1:5004 check