mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
* released 1.1.5
* connection logging displayed incorrect source address. * added proxy start/stop and server up/down log events. * replaced log message short buffers with larger trash. * enlarged buffer to 8 kB and replace buffer to 4 kB. * added a config.rc example for Formilux * added a build script for Formilux
This commit is contained in:
parent
e47c8d7279
commit
535ae7aee2
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
H A - P r o x y
|
H A - P r o x y
|
||||||
---------------
|
---------------
|
||||||
version 1.1.4
|
version 1.1.5
|
||||||
willy tarreau
|
willy tarreau
|
||||||
2002/03/25
|
2002/04/03
|
||||||
|
|
||||||
================
|
================
|
||||||
| Introduction |
|
| Introduction |
|
||||||
@ -403,7 +403,8 @@ Exemple :
|
|||||||
|
|
||||||
Les connexions sont envoyées en niveau "info". Les démarrages de
|
Les connexions sont envoyées en niveau "info". Les démarrages de
|
||||||
service seront envoyés en "notice", les signaux d'arrêts en "warning"
|
service seront envoyés en "notice", les signaux d'arrêts en "warning"
|
||||||
et les arrêts définitifs en "alert".
|
et les arrêts définitifs en "alert". Ceci est valable aussi bien
|
||||||
|
pour les proxies que pour les serveurs testés au sein des proxies.
|
||||||
|
|
||||||
Les catégories possibles sont :
|
Les catégories possibles sont :
|
||||||
kern, user, mail, daemon, auth, syslog, lpr, news,
|
kern, user, mail, daemon, auth, syslog, lpr, news,
|
||||||
@ -463,9 +464,10 @@ Remarques :
|
|||||||
- 'reqrep' est l'équivalent de 'cliexp' en version 1.0, et 'rsprep' celui de
|
- 'reqrep' est l'équivalent de 'cliexp' en version 1.0, et 'rsprep' celui de
|
||||||
'srvexp'. Ces noms sont toujours supportés mais déconseillés.
|
'srvexp'. Ces noms sont toujours supportés mais déconseillés.
|
||||||
- pour des raisons de performances, le nombre total de caractères ajoutés sur
|
- pour des raisons de performances, le nombre total de caractères ajoutés sur
|
||||||
une requête ou une réponse est limité à 256. Cette valeur est modifiable dans
|
une requête ou une réponse est limité à 4096 depuis la version 1.1.5 (cette
|
||||||
le code. Pour un usage temporaire, on peut gagner de la place en supprimant
|
limite était à 256 auparavant). Cette valeur est modifiable dans le code.
|
||||||
quelques entêtes inutiles avant les ajouts.
|
Pour un usage temporaire, on peut gagner de la place en supprimant quelques
|
||||||
|
entêtes inutiles avant les ajouts.
|
||||||
|
|
||||||
Exemples :
|
Exemples :
|
||||||
--------
|
--------
|
||||||
|
4
examples/config.rc.haproxy
Normal file
4
examples/config.rc.haproxy
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
service haproxy
|
||||||
|
config /etc/haproxy/haproxy.cfg
|
||||||
|
maxconn 1024
|
||||||
|
|
16
examples/haproxy-1.1.5-flx.1-i686.pkg
Normal file
16
examples/haproxy-1.1.5-flx.1-i686.pkg
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
function do_compile {
|
||||||
|
make COPTS="-march=i586 -mcpu=i686 -O2 -mpreferred-stack-boundary=2 -malign-loops=0 -malign-jumps=0 -DNETFILTER -DTRANSPARENT"
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_prepack {
|
||||||
|
mkdir -p $ROOTDIR/sbin/init.d ; cp init.d/haproxy $ROOTDIR/sbin/init.d
|
||||||
|
mkdir -p $ROOTDIR/usr/sbin ; cp haproxy $ROOTDIR/usr/sbin
|
||||||
|
mkdir -p $ROOTDIR/usr/share/sample/etc/haproxy ; cp examples/cfg $ROOTDIR/usr/share/sample/etc/haproxy/haproxy.cfg
|
||||||
|
cp examples/rc.highsock $ROOTDIR/usr/share/sample/etc/haproxy/rc.highsock
|
||||||
|
cp examples/config.rc.haproxy $ROOTDIR/usr/share/sample/etc/config.rc.haproxy
|
||||||
|
mkdir -p $ROOTDIR/usr/share/haproxy ; cp doc/haproxy.txt $ROOTDIR/usr/share/haproxy
|
||||||
|
make clean
|
||||||
|
}
|
||||||
|
|
100
haproxy.c
100
haproxy.c
@ -13,6 +13,12 @@
|
|||||||
*
|
*
|
||||||
* ChangeLog :
|
* ChangeLog :
|
||||||
*
|
*
|
||||||
|
* 2002/04/03
|
||||||
|
* - released 1.1.5
|
||||||
|
* - connection logging displayed incorrect source address.
|
||||||
|
* - added proxy start/stop and server up/down log events.
|
||||||
|
* - replaced log message short buffers with larger trash.
|
||||||
|
* - enlarged buffer to 8 kB and replace buffer to 4 kB.
|
||||||
* 2002/03/25
|
* 2002/03/25
|
||||||
* - released 1.1.4
|
* - released 1.1.4
|
||||||
* - made rise/fall/interval time configurable
|
* - made rise/fall/interval time configurable
|
||||||
@ -102,8 +108,8 @@
|
|||||||
#include <linux/netfilter_ipv4.h>
|
#include <linux/netfilter_ipv4.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HAPROXY_VERSION "1.1.4"
|
#define HAPROXY_VERSION "1.1.5"
|
||||||
#define HAPROXY_DATE "2002/03/25"
|
#define HAPROXY_DATE "2002/04/03"
|
||||||
|
|
||||||
/* this is for libc5 for example */
|
/* this is for libc5 for example */
|
||||||
#ifndef TCP_NODELAY
|
#ifndef TCP_NODELAY
|
||||||
@ -118,10 +124,10 @@
|
|||||||
#define SHUT_WR 1
|
#define SHUT_WR 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BUFSIZE 4096
|
#define BUFSIZE 8192
|
||||||
|
|
||||||
// reserved buffer space for header rewriting
|
// reserved buffer space for header rewriting
|
||||||
#define MAXREWRITE 256
|
#define MAXREWRITE 4096
|
||||||
|
|
||||||
// max # args on a configuration line
|
// max # args on a configuration line
|
||||||
#define MAX_LINE_ARGS 10
|
#define MAX_LINE_ARGS 10
|
||||||
@ -330,6 +336,7 @@ struct server {
|
|||||||
int inter; /* time in milliseconds */
|
int inter; /* time in milliseconds */
|
||||||
int result; /* 0 = connect OK, -1 = connect KO */
|
int result; /* 0 = connect OK, -1 = connect KO */
|
||||||
int curfd; /* file desc used for current test, or -1 if not in test */
|
int curfd; /* file desc used for current test, or -1 if not in test */
|
||||||
|
struct proxy *proxy; /* the proxy this server belongs to */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The base for all tasks */
|
/* The base for all tasks */
|
||||||
@ -1559,30 +1566,25 @@ int event_accept(int fd) {
|
|||||||
|
|
||||||
if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP)
|
if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP)
|
||||||
&& (p->logfac1 >= 0 || p->logfac2 >= 0)) {
|
&& (p->logfac1 >= 0 || p->logfac2 >= 0)) {
|
||||||
struct sockaddr_in peername, sockname;
|
struct sockaddr_in sockname;
|
||||||
unsigned char *pn, *sn;
|
unsigned char *pn, *sn;
|
||||||
int namelen;
|
int namelen;
|
||||||
char message[256];
|
|
||||||
|
|
||||||
//namelen = sizeof(peername);
|
|
||||||
//getpeername(cfd, (struct sockaddr *)&peername, &namelen);
|
|
||||||
//pn = (unsigned char *)&peername.sin_addr;
|
|
||||||
pn = (unsigned char *)&s->cli_addr;
|
|
||||||
|
|
||||||
namelen = sizeof(sockname);
|
namelen = sizeof(sockname);
|
||||||
if (get_original_dst(cfd, (struct sockaddr_in *)&sockname, &namelen) == -1)
|
if (get_original_dst(cfd, (struct sockaddr_in *)&sockname, &namelen) == -1)
|
||||||
getsockname(cfd, (struct sockaddr *)&sockname, &namelen);
|
getsockname(cfd, (struct sockaddr *)&sockname, &namelen);
|
||||||
sn = (unsigned char *)&sockname.sin_addr;
|
sn = (unsigned char *)&sockname.sin_addr;
|
||||||
|
pn = (unsigned char *)&s->cli_addr.sin_addr;
|
||||||
|
|
||||||
sprintf(message, "Connect from %d.%d.%d.%d:%d to %d.%d.%d.%d:%d (%s/%s)\n",
|
sprintf(trash, "Connect from %d.%d.%d.%d:%d to %d.%d.%d.%d:%d (%s/%s)\n",
|
||||||
pn[0], pn[1], pn[2], pn[3], ntohs(peername.sin_port),
|
pn[0], pn[1], pn[2], pn[3], ntohs(s->cli_addr.sin_port),
|
||||||
sn[0], sn[1], sn[2], sn[3], ntohs(sockname.sin_port),
|
sn[0], sn[1], sn[2], sn[3], ntohs(sockname.sin_port),
|
||||||
p->id, (p->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
|
p->id, (p->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
|
||||||
|
|
||||||
if (p->logfac1 >= 0)
|
if (p->logfac1 >= 0)
|
||||||
send_syslog(&p->logsrv1, p->logfac1, LOG_INFO, message);
|
send_syslog(&p->logsrv1, p->logfac1, LOG_INFO, trash);
|
||||||
if (p->logfac2 >= 0)
|
if (p->logfac2 >= 0)
|
||||||
send_syslog(&p->logsrv2, p->logfac2, LOG_INFO, message);
|
send_syslog(&p->logsrv2, p->logfac2, LOG_INFO, trash);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mode & MODE_DEBUG) && !(mode & MODE_QUIET)) {
|
if ((mode & MODE_DEBUG) && !(mode & MODE_QUIET)) {
|
||||||
@ -2741,8 +2743,18 @@ int process_chk(struct task *t) {
|
|||||||
if (s->health > s->rise)
|
if (s->health > s->rise)
|
||||||
s->health--; /* still good */
|
s->health--; /* still good */
|
||||||
else {
|
else {
|
||||||
if (s->health == s->rise && !(mode & MODE_QUIET))
|
if (s->health == s->rise) {
|
||||||
Warning("server %s DOWN.\n", s->id);
|
if (!(mode & MODE_QUIET))
|
||||||
|
Warning("server %s DOWN.\n", s->id);
|
||||||
|
|
||||||
|
sprintf(trash, "Server %s/%s is DOWN.\n",
|
||||||
|
s->proxy->id, s->id);
|
||||||
|
|
||||||
|
if (s->proxy->logfac1 >= 0)
|
||||||
|
send_syslog(&s->proxy->logsrv1, s->proxy->logfac1, LOG_ALERT, trash);
|
||||||
|
if (s->proxy->logfac2 >= 0)
|
||||||
|
send_syslog(&s->proxy->logsrv2, s->proxy->logfac2, LOG_ALERT, trash);
|
||||||
|
}
|
||||||
|
|
||||||
s->health = 0; /* failure */
|
s->health = 0; /* failure */
|
||||||
s->state &= ~SRV_RUNNING;
|
s->state &= ~SRV_RUNNING;
|
||||||
@ -2759,8 +2771,16 @@ int process_chk(struct task *t) {
|
|||||||
//fprintf(stderr, "process_chk: 9\n");
|
//fprintf(stderr, "process_chk: 9\n");
|
||||||
s->health++; /* was bad, stays for a while */
|
s->health++; /* was bad, stays for a while */
|
||||||
if (s->health >= s->rise) {
|
if (s->health >= s->rise) {
|
||||||
if (s->health == s->rise && !(mode & MODE_QUIET))
|
if (s->health == s->rise) {
|
||||||
Warning("server %s UP.\n", s->id);
|
if (!(mode & MODE_QUIET))
|
||||||
|
Warning("server %s UP.\n", s->id);
|
||||||
|
sprintf(trash, "Server %s/%s is UP.\n", s->proxy->id, s->id);
|
||||||
|
|
||||||
|
if (s->proxy->logfac1 >= 0)
|
||||||
|
send_syslog(&s->proxy->logsrv1, s->proxy->logfac1, LOG_NOTICE, trash);
|
||||||
|
if (s->proxy->logfac2 >= 0)
|
||||||
|
send_syslog(&s->proxy->logsrv2, s->proxy->logfac2, LOG_NOTICE, trash);
|
||||||
|
}
|
||||||
|
|
||||||
s->health = s->rise + s->fall - 1; /* OK now */
|
s->health = s->rise + s->fall - 1; /* OK now */
|
||||||
s->state |= SRV_RUNNING;
|
s->state |= SRV_RUNNING;
|
||||||
@ -2776,8 +2796,17 @@ int process_chk(struct task *t) {
|
|||||||
if (s->health > s->rise)
|
if (s->health > s->rise)
|
||||||
s->health--; /* still good */
|
s->health--; /* still good */
|
||||||
else {
|
else {
|
||||||
if (s->health == s->rise && !(mode & MODE_QUIET))
|
if (s->health == s->rise) {
|
||||||
Warning("server %s DOWN.\n", s->id);
|
if (!(mode & MODE_QUIET))
|
||||||
|
Warning("server %s DOWN.\n", s->id);
|
||||||
|
sprintf(trash, "Server %s/%s is DOWN.\n",
|
||||||
|
s->proxy->id, s->id);
|
||||||
|
|
||||||
|
if (s->proxy->logfac1 >= 0)
|
||||||
|
send_syslog(&s->proxy->logsrv1, s->proxy->logfac1, LOG_ALERT, trash);
|
||||||
|
if (s->proxy->logfac2 >= 0)
|
||||||
|
send_syslog(&s->proxy->logsrv2, s->proxy->logfac2, LOG_ALERT, trash);
|
||||||
|
}
|
||||||
|
|
||||||
s->health = 0; /* failure */
|
s->health = 0; /* failure */
|
||||||
s->state &= ~SRV_RUNNING;
|
s->state &= ~SRV_RUNNING;
|
||||||
@ -3034,8 +3063,14 @@ static int maintain_proxies(void) {
|
|||||||
int t;
|
int t;
|
||||||
t = tv_remain(&now, &p->stop_time);
|
t = tv_remain(&now, &p->stop_time);
|
||||||
if (t == 0) {
|
if (t == 0) {
|
||||||
//FD_CLR(p->listen_fd, StaticReadEvent);
|
Warning("Proxy %s stopped.\n", p->id);
|
||||||
//close(p->listen_fd);
|
sprintf(trash, "Proxy %s stopped.\n", p->id);
|
||||||
|
|
||||||
|
if (p->logfac1 >= 0)
|
||||||
|
send_syslog(&p->logsrv1, p->logfac1, LOG_WARNING, trash);
|
||||||
|
if (p->logfac2 >= 0)
|
||||||
|
send_syslog(&p->logsrv2, p->logfac2, LOG_WARNING, trash);
|
||||||
|
|
||||||
fd_delete(p->listen_fd);
|
fd_delete(p->listen_fd);
|
||||||
p->state = PR_STDISABLED;
|
p->state = PR_STDISABLED;
|
||||||
listeners--;
|
listeners--;
|
||||||
@ -3061,8 +3096,16 @@ static void soft_stop(void) {
|
|||||||
p = proxy;
|
p = proxy;
|
||||||
tv_now(&now); /* else, the old time before select will be used */
|
tv_now(&now); /* else, the old time before select will be used */
|
||||||
while (p) {
|
while (p) {
|
||||||
if (p->state != PR_STDISABLED)
|
if (p->state != PR_STDISABLED) {
|
||||||
|
Warning("Stopping proxy %s in %d ms.\n", p->id, p->grace);
|
||||||
|
sprintf(trash, "Stopping proxy %s in %d ms.\n", p->id, p->grace);
|
||||||
|
|
||||||
|
if (p->logfac1 >= 0)
|
||||||
|
send_syslog(&p->logsrv1, p->logfac1, LOG_WARNING, trash);
|
||||||
|
if (p->logfac2 >= 0)
|
||||||
|
send_syslog(&p->logsrv2, p->logfac2, LOG_WARNING, trash);
|
||||||
tv_delayfrom(&p->stop_time, &now, p->grace);
|
tv_delayfrom(&p->stop_time, &now, p->grace);
|
||||||
|
}
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3384,6 +3427,7 @@ int readcfgfile(char *file) {
|
|||||||
}
|
}
|
||||||
newsrv->next = curproxy->srv;
|
newsrv->next = curproxy->srv;
|
||||||
curproxy->srv = newsrv;
|
curproxy->srv = newsrv;
|
||||||
|
newsrv->proxy = curproxy;
|
||||||
newsrv->id = strdup(args[1]);
|
newsrv->id = strdup(args[1]);
|
||||||
newsrv->addr = *str2sa(args[2]);
|
newsrv->addr = *str2sa(args[2]);
|
||||||
newsrv->state = SRV_RUNNING; /* early server setup */
|
newsrv->state = SRV_RUNNING; /* early server setup */
|
||||||
@ -3852,6 +3896,14 @@ int start_proxies() {
|
|||||||
fd_insert(fd);
|
fd_insert(fd);
|
||||||
listeners++;
|
listeners++;
|
||||||
// fprintf(stderr,"Proxy %s : socket bound.\n", curproxy->id);
|
// fprintf(stderr,"Proxy %s : socket bound.\n", curproxy->id);
|
||||||
|
|
||||||
|
sprintf(trash, "Proxy %s started.\n", curproxy->id);
|
||||||
|
|
||||||
|
if (curproxy->logfac1 >= 0)
|
||||||
|
send_syslog(&curproxy->logsrv1, curproxy->logfac1, LOG_INFO, trash);
|
||||||
|
if (curproxy->logfac2 >= 0)
|
||||||
|
send_syslog(&curproxy->logsrv2, curproxy->logfac2, LOG_INFO, trash);
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,40 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# config.rc sample with defaults :
|
||||||
|
# service haproxy
|
||||||
|
# config /etc/haproxy/haproxy.cfg
|
||||||
|
# maxconn 1024
|
||||||
|
#
|
||||||
|
config="/etc/haproxy/haproxy.cfg"
|
||||||
|
maxconn=1024
|
||||||
|
|
||||||
bin=/usr/sbin/haproxy
|
bin=/usr/sbin/haproxy
|
||||||
cmdline='$bin -D -f /etc/haproxy/haproxy.cfg'
|
cmdline='$bin -D'
|
||||||
|
|
||||||
. $ROOT/sbin/init.d/default
|
. $ROOT/sbin/init.d/default
|
||||||
|
|
||||||
# arret en douceur
|
if [ -e "$config" ]; then
|
||||||
|
maintfd=`grep '^\([^#]*\)\(listen\|server\)' $config|wc -l`
|
||||||
|
else
|
||||||
|
maintfd=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
maxfd=$[$maxconn*2 + $maintfd]
|
||||||
|
if [ $maxfd -lt 100 ]; then
|
||||||
|
maxfd=100;
|
||||||
|
fi
|
||||||
|
cmdline="$cmdline -n $maxconn -f $config"
|
||||||
|
ulimit -n $maxfd
|
||||||
|
|
||||||
|
# to get a core when needed, uncomment the following :
|
||||||
|
# cd /var/tmp
|
||||||
|
# ulimit -c unlimited
|
||||||
|
|
||||||
|
# soft stop
|
||||||
function dostop {
|
function dostop {
|
||||||
pids=`pidof -o $$ -- $PNAME`
|
pids=`pidof -o $$ -- $PNAME`
|
||||||
if [ ! -z "$pids" ]; then
|
if [ ! -z "$pids" ]; then
|
||||||
echo "Asking $PNAME to terminate asap..."
|
echo "Asking $PNAME to terminate gracefully..."
|
||||||
kill -USR1 $pids
|
kill -USR1 $pids
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user