mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-31 23:58:16 +00:00
* released 1.2.5-pre1
* build fixes for appsession * documentation for appsession
This commit is contained in:
parent
12350155a4
commit
598da41537
@ -100,6 +100,7 @@ the following ones :
|
|||||||
- debug
|
- debug
|
||||||
- quiet
|
- quiet
|
||||||
- pidfile <file>
|
- pidfile <file>
|
||||||
|
- stats
|
||||||
|
|
||||||
1.1) Event logging
|
1.1) Event logging
|
||||||
------------------
|
------------------
|
||||||
@ -623,6 +624,33 @@ Example : the 'SERVERID' cookie can be either 'server01' or 'server02'
|
|||||||
Warning : the syntax has changed since version 1.0 !
|
Warning : the syntax has changed since version 1.0 !
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
2.11) Application Cookies
|
||||||
|
-------------------------
|
||||||
|
Since 1.2.4 it is possible to catch the cookie that comes from an
|
||||||
|
application server in order to apply "application session stickyness".
|
||||||
|
The server's response is searched for 'appsession' cookie, the first
|
||||||
|
'len' bytes are used for matching and it is stored for a period of
|
||||||
|
'timeout'.
|
||||||
|
The syntax is:
|
||||||
|
|
||||||
|
appsession <SESSIONCOOKIE> len <MATCHLENGTH> timeout <HOLDTIME>
|
||||||
|
|
||||||
|
- <SESSIONCOOKIE> is the cookie, the server uses for it's session-handling
|
||||||
|
- <MATCHLENGTH> how many bytes/characters should be used for matching equal
|
||||||
|
sessions
|
||||||
|
- <HOLDTIME> after this inactivaty time, in ms, the cookie will be deleted
|
||||||
|
from the sessionstore
|
||||||
|
|
||||||
|
The appsession is only per 'listen' section possible.
|
||||||
|
|
||||||
|
Example :
|
||||||
|
---------
|
||||||
|
listen http_proxy :80
|
||||||
|
mode http
|
||||||
|
appsession JSESSIONID len 52 timeout 300000
|
||||||
|
.
|
||||||
|
.
|
||||||
|
|
||||||
3) Autonomous load balancer
|
3) Autonomous load balancer
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
@ -1448,8 +1476,8 @@ Example :
|
|||||||
mode http
|
mode http
|
||||||
cookie SERVERID insert nocache indirect
|
cookie SERVERID insert nocache indirect
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
server 192.168.1.1:80 cookie server01 check
|
server srv1 192.168.1.1:80 cookie server01 check
|
||||||
server 192.168.1.2:80 cookie server02 check
|
server srv2 192.168.1.2:80 cookie server02 check
|
||||||
|
|
||||||
The other solution brought by versions 1.1.30 and 1.2.3 is to reuse a cookie
|
The other solution brought by versions 1.1.30 and 1.2.3 is to reuse a cookie
|
||||||
from the server, and prefix the server's name to it. In this case, don't forget
|
from the server, and prefix the server's name to it. In this case, don't forget
|
||||||
@ -1460,8 +1488,8 @@ request will have its cookie fixed.
|
|||||||
mode http
|
mode http
|
||||||
cookie JSESSIONID prefix
|
cookie JSESSIONID prefix
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
server 192.168.1.1:80 cookie srv1 check
|
server srv1 192.168.1.1:80 cookie srv1 check
|
||||||
server 192.168.1.2:80 cookie srv2 check
|
server srv2 192.168.1.2:80 cookie srv2 check
|
||||||
option httpclose
|
option httpclose
|
||||||
|
|
||||||
|
|
||||||
|
@ -1497,8 +1497,8 @@ Exemple :
|
|||||||
mode http
|
mode http
|
||||||
cookie SERVERID insert nocache indirect
|
cookie SERVERID insert nocache indirect
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
server 192.168.1.1:80 cookie server01 check
|
server srv1 192.168.1.1:80 cookie server01 check
|
||||||
server 192.168.1.2:80 cookie server02 check
|
server srv2 192.168.1.2:80 cookie server02 check
|
||||||
|
|
||||||
L'autre solution apportée par les versions 1.1.30 et 1.2.3 est de réutiliser un
|
L'autre solution apportée par les versions 1.1.30 et 1.2.3 est de réutiliser un
|
||||||
cookie en provenance du serveur et de lui préfixer l'identifiant du serveur.
|
cookie en provenance du serveur et de lui préfixer l'identifiant du serveur.
|
||||||
@ -1510,8 +1510,8 @@ puisse corriger le nom du cookie dans toutes les futures requ
|
|||||||
mode http
|
mode http
|
||||||
cookie JSESSIONID prefix
|
cookie JSESSIONID prefix
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
server 192.168.1.1:80 cookie srv1 check
|
server srv1 192.168.1.1:80 cookie srv1 check
|
||||||
server 192.168.1.2:80 cookie srv2 check
|
server srv2 192.168.1.2:80 cookie srv2 check
|
||||||
option httpclose
|
option httpclose
|
||||||
|
|
||||||
|
|
||||||
|
44
haproxy.c
44
haproxy.c
@ -61,45 +61,7 @@
|
|||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TBLSIZ 10
|
#include "include/appsession.h"
|
||||||
#define TBLCHKINT 5000 /* The time between two calls of appsession_refresh in ms */
|
|
||||||
|
|
||||||
/*
|
|
||||||
These Parts are copied from
|
|
||||||
|
|
||||||
http://www.oreilly.com/catalog/masteralgoc/index.html
|
|
||||||
Mastering Algorithms with C
|
|
||||||
By Kyle Loudon
|
|
||||||
ISBN: 1-56592-453-3
|
|
||||||
Publishd by O'Reilly
|
|
||||||
|
|
||||||
We have added our own struct to these function.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <include/list.h>
|
|
||||||
#include <include/chtbl.h>
|
|
||||||
#include <include/hashpjw.h>
|
|
||||||
/* end of copied parts */
|
|
||||||
|
|
||||||
struct app_pool {
|
|
||||||
void **sessid;
|
|
||||||
void **serverid;
|
|
||||||
int ses_waste, ses_use, ses_msize;
|
|
||||||
int ser_waste, ser_use, ser_msize;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct app_pool apools;
|
|
||||||
int have_appsession;
|
|
||||||
|
|
||||||
/* Callback for hash_lookup */
|
|
||||||
int match_str(const void *key1, const void *key2);
|
|
||||||
|
|
||||||
/* Callback for destroy */
|
|
||||||
void destroy(void *data);
|
|
||||||
|
|
||||||
#if defined(DEBUG_HASH)
|
|
||||||
static void print_table(const CHTbl *htbl);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define HAPROXY_VERSION "1.2.4"
|
#define HAPROXY_VERSION "1.2.4"
|
||||||
#define HAPROXY_DATE "2005/01/22"
|
#define HAPROXY_DATE "2005/01/22"
|
||||||
@ -2956,12 +2918,11 @@ int process_cli(struct session *t) {
|
|||||||
srv = srv->next;
|
srv = srv->next;
|
||||||
}/* end while(srv) */
|
}/* end while(srv) */
|
||||||
}/* end else of if (asession_temp->serverid == NULL) */
|
}/* end else of if (asession_temp->serverid == NULL) */
|
||||||
|
|
||||||
method_checked = 1;
|
|
||||||
}/* end if(strncasecmp(request_line,t->proxy->appsession_name,apssesion_name_len) == 0) */
|
}/* end if(strncasecmp(request_line,t->proxy->appsession_name,apssesion_name_len) == 0) */
|
||||||
else {
|
else {
|
||||||
//fprintf(stderr,">>>>>>>>>>>>>>>>>>>>>>NO SESSION\n");
|
//fprintf(stderr,">>>>>>>>>>>>>>>>>>>>>>NO SESSION\n");
|
||||||
}
|
}
|
||||||
|
method_checked = 1;
|
||||||
}/* end if(!method_checked ...) */
|
}/* end if(!method_checked ...) */
|
||||||
else{
|
else{
|
||||||
//printf("No Methode-Header with Session-String\n");
|
//printf("No Methode-Header with Session-String\n");
|
||||||
@ -3311,7 +3272,6 @@ int process_cli(struct session *t) {
|
|||||||
}/* end else if server == NULL */
|
}/* end else if server == NULL */
|
||||||
|
|
||||||
tv_delayfrom(&asession_temp->expire, &now, t->proxy->appsession_timeout);
|
tv_delayfrom(&asession_temp->expire, &now, t->proxy->appsession_timeout);
|
||||||
break;
|
|
||||||
}/* end if ((t->proxy->appsession_name != NULL) ... */
|
}/* end if ((t->proxy->appsession_name != NULL) ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
include/appsession.h
Normal file
44
include/appsession.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#ifndef _APPSESS_H
|
||||||
|
#define _APPSESS_H
|
||||||
|
|
||||||
|
#define TBLSIZ 10
|
||||||
|
#define TBLCHKINT 5000 /* The time between two calls of appsession_refresh in ms */
|
||||||
|
|
||||||
|
/*
|
||||||
|
These Parts are copied from
|
||||||
|
|
||||||
|
http://www.oreilly.com/catalog/masteralgoc/index.html
|
||||||
|
Mastering Algorithms with C
|
||||||
|
By Kyle Loudon
|
||||||
|
ISBN: 1-56592-453-3
|
||||||
|
Publishd by O'Reilly
|
||||||
|
|
||||||
|
We have added our own struct to these function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <include/list.h>
|
||||||
|
#include <include/chtbl.h>
|
||||||
|
#include <include/hashpjw.h>
|
||||||
|
/* end of copied parts */
|
||||||
|
|
||||||
|
struct app_pool {
|
||||||
|
void **sessid;
|
||||||
|
void **serverid;
|
||||||
|
int ses_waste, ses_use, ses_msize;
|
||||||
|
int ser_waste, ser_use, ser_msize;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct app_pool apools;
|
||||||
|
int have_appsession;
|
||||||
|
|
||||||
|
/* Callback for hash_lookup */
|
||||||
|
int match_str(const void *key1, const void *key2);
|
||||||
|
|
||||||
|
/* Callback for destroy */
|
||||||
|
void destroy(void *data);
|
||||||
|
|
||||||
|
#if defined(DEBUG_HASH)
|
||||||
|
static void print_table(const CHTbl *htbl);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -28,7 +28,7 @@ int hashpjw(const void *key) {
|
|||||||
|
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
AppSess *appsession_temp;
|
appsess *appsession_temp;
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* *
|
* *
|
||||||
@ -37,7 +37,7 @@ int hashpjw(const void *key) {
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
val = 0;
|
val = 0;
|
||||||
appsession_temp = (AppSess *)key;
|
appsession_temp = (appsess *)key;
|
||||||
ptr = appsession_temp->sessid;
|
ptr = appsession_temp->sessid;
|
||||||
|
|
||||||
while (*ptr != '\0') {
|
while (*ptr != '\0') {
|
||||||
|
Loading…
Reference in New Issue
Block a user