crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs

sample.conf (6542B)


      1 /*
      2  * Sample configuration for crossroads
      3  * Default location of this is /etc/crossroads.conf, unless overruled by -c.
      4  */
      5 
      6 # Empty lines are allowed, # shell-style comment too.
      7 // And C++ style comment as well.
      8 
      9 /* Service www: TCP activity on port 8000 gets distributed
     10  * over a couple of webserver back ends.
     11  */
     12 service www {
     13     
     14     /* Port on which we'll listen in this service: required. */
     15     port 8000;
     16 
     17     /* What IP address should this service listen? Default is 'any'.
     18      * Alternatively you can state an explicit IP address, such as
     19      * 127.0.0.1; that would bind the service only to 'localhost'. */
     20     bindto any;
     21     
     22     /* Verbose reporting or not. Default is off. */    
     23     verbosity on;
     24 
     25     /* Service type: 'http' or 'any'. With 'http' you can make sessions
     26      * "stick" to a once selected back end. If you don't need stickiness,
     27      * use 'any' which is the default. */
     28     type any;
     29     
     30     /* Dispatching mode, or: How to select a back end for an incoming
     31      * request. Possible values:
     32      *   roundrobin: just the next back end in line
     33      *   random: like roundrobin, but at random to make things more
     34      *          confusing. Probably only good for testing.
     35      *   bysize: The backend that transferred the least nr of bytes
     36      *          is the next in line. As a modifier you can say e.g.
     37      *          bysize over 10, meaning that the 10 last connections will
     38      *          be used to compute the transfer size, instead of all
     39      *          transfers.
     40      *   byduration: The backend that was active for the shortest time
     41      *          is the next in line. As a modifier you can say e.g.
     42      *          byduration of 10 to compute over the last 10 connections.
     43      *	 byconnections: The back end with the least number of active
     44      * 		connections is the next in line.
     45      *   byorder: The first available back end is always taken.
     46      */
     47     dispatchmode byduration over 5;
     48 
     49     /* Interval at which we'll check whether a temporarily unavailable
     50      * backend has woken up.
     51      */
     52     revivinginterval 5;
     53     
     54     /* TCP backlog of connections. Default is 0 (no backlog, one
     55      * connection may be active).
     56      */
     57     backlog 5;
     58     
     59     /* For status reporting: a shared memory key. Default is the same
     60      * as the port number, OR-ed by a magic number.
     61      */
     62     shmkey 8000;
     63 
     64     /* This controls when crossroads should consider a connection as
     65      * finished even when the TCP sockets weren't closed. This is to
     66      * avoid hanging connections that don't do anything. NOTE THAT when
     67      * crossroads cuts off a connection due to timeout exceed, this is
     68      * not marked as a failure, but as a success. Default is 0: no timeout.
     69      */
     70     connectiontimeout 300;
     71 
     72     /* The max number of allowed client connections. When present, connections
     73      * won't be accepted if the max is about to be exceeded. When
     74      * absent, all connections will be accepted, which might be misused
     75      * for a DOS attack.
     76      */
     77     maxconnections 300;
     78 
     79     /* Now let's define a couple of back ends. Number 1: */
     80     backend www_backend_1 {
     81         /* The server and its port, the minimum configuration. */
     82         server httpserver1;
     83         port 9010;
     84 
     85         /* The 'decay' of usage data of this back end. Only relevant
     86          * when the whole service has 'dispatchmode bysize' or
     87          * 'byduration'. The number is a percentage by which the usage
     88          * parameter is decreased upon each connection of an other back
     89          * end.
     90          */
     91         decay 10;
     92         
     93         /* To see what's happening in /var/log/messages: */
     94         verbosity on;
     95     }
     96 
     97     /* The second one. For this back end we want to see the response
     98      * times, so we specify a throughput log. */
     99     backend www_backend_2 {
    100         /* Server and port. You can use a shorthand for both host and port: */
    101         server httpserver2:9011;
    102 
    103         /* Verbosity of reporting when this back end is active */
    104         verbosity on;
    105 
    106         /* Decay */
    107         decay 10;
    108 
    109 	/* Performance related */
    110 	throughputlog /tmp/backend.2.perflog;
    111 
    112         /* Event triggers for system commands upon succesful activation
    113          * and upon failure.
    114          */
    115         onsuccess echo 'success on backend 2' | mail root;
    116         onfailure echo 'failure on backend 2' | mail root;
    117     }
    118 
    119     /* And yet another one.. this time we will dump the traffic
    120      * to a trace file. Furthermore we don't want more than 10 concurrent
    121      * connections here. Note that there's also a total maxconnections for the
    122      * whole service.
    123      */
    124     backend www_backend_3 {
    125         server httpserver3:9000;
    126         verbosity on;
    127         decay 10;
    128         trafficlog /tmp/backend.3.log;
    129 	maxconnections 10;
    130     }
    131 }
    132 
    133 /* Another example: SSH login failover. */
    134 service ssh {
    135     port 2222;                          // Incoming port
    136     type any;				// Generic TCP service
    137     verbosity on;                       // Let's be verbose
    138     shmkey 2222;                        // Shared memory related
    139     connectiontimeout 30;               // Auto-logout after 30 secs
    140     dispatchmode bysize over 1;         // Least bytes = least active,
    141                                         // only last connection matters
    142     maxconnections 1;                   // 1 concurrent login
    143     
    144     backend ssh_1 {                     // First back end
    145         server sshserver1:22;
    146         verbosity on;
    147         onfailure echo 'SSH failure on sshserver1' | mail root;
    148     }
    149     
    150     backend ssh_2 {                     // Second back end
    151         server sshserver2:22;
    152         verbosity on;
    153         onfailure echo 'SSH failure on sshserver2' | mail root;
    154     }
    155 }
    156 
    157 /* Yet another example: sticky HTTP for an application that's hosted on
    158  * 3 back ends, but the each of the apps isn't session-aware of the others.
    159  * As for the balancing we'll simply round-robin it.
    160  */
    161 service balancedapp {
    162     port 8001;
    163     type stickyhttp;
    164     backend app1 {
    165 	server appserver1:8080;
    166 	/* If 'BalancerID=a' is already in the browser's request, then
    167 	 * the request automatically goes to this backend */
    168 	stickycookie BalancerID=a;
    169 	/* The server return is enriched with the following cookie
    170 	 * instruction (note that this matches 'stickycookie' above) */
    171 	insertcookie "BalancerID=a; Path=/";
    172     }
    173     backend app2 {
    174 	server appserver2:8080;
    175 	stickycookie BalancerID=b;
    176 	insertcookie "BalancerID=b; Path=/";
    177     }
    178     backend app3 {
    179 	server appserver3:8080;
    180 	stickycookie BalancerID=c;
    181 	insertcookie "BalancerID=c; Path=/";
    182     }
    183 }
    184