Brane F. Gračnar <brane.gracnar@...> writes:
>
> On Wednesday 15 of June 2011 21:59:34 Igor wrote:
> > Got a very long haproxy.conf, is there any way to separate config file
> > by using any directive like include *.conf?
>
> I wrote a patch for this some time ago, it applies to 1.4.15 and 1.5-dev6,
i'm
> using it in production.
>
> http://www.mail-archive.com/haproxy-JklxK3liFipg9hUCZPvPmw <at>
public.gmane.org/msg04100.html
>
> However, Willy has strong opinion against using include statement, and to
some
> degree, he has a point.
>
> Best regards, Brane
>
>
We recreated the same structure and functionality as the Apache2-style as we
also wanted the easier management.
Below shows the directory structure and files we modified to make this happen.
Modified /etc/init.d/haproxy:
EXTRAOPTS=`for FILE in \`find /etc/haproxy/sites-enabled -type l | sort
-n\`; do CONFIGS="$CONFIGS -f $FILE"; done; echo $CONFIGS`
/etc/haproxy
├── errors
│ ├── 400.http
│ ├── 403.http
│ ├── 408.http
│ ├── 500.http
│ ├── 502.http
│ ├── 503.http
│ └── 504.http
├── haproxy.cfg
├── haproxy.cfg.bak
├── haproxy.cfg.bak-2014-03-21
├── sites-available
│ ├── site01.example.com
│ ├── site02.example.com
│ └── site03.exmaple.com
└── sites-enabled
├── site01.example.com -> ../sites-available/site01.example.com
├── site02.example.com -> ../sites-available/site02.example.com
└── site03.example.com -> ../sites-available/site03.example.com
Created haensite:
#############################
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "You must be a root user" 2>&1
exit 1
fi
if [ $# -lt 1 ]; then
echo "Invalid number of arguments"
exit 1
fi
echo "Enabling $1..."
cd /etc/haproxy/sites-enabled
ln -s ../sites-available/$1 ./
echo "To activate the new configuration, you need to run:"
echo " /etc/init.d/haproxy restart"
Created hadissite:
#############################
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "You must be a root user" 2>&1
exit 1
fi
if [ $# -lt 1 ]; then
echo "Invalid number of arguments"
exit 1
fi
echo "Disabling $1..."
rm -f /etc/haproxy/sites-enabled/$1
echo "To activate the new configuration, you need to run:"
echo " /etc/init.d/haproxy restart"