├── poundctl.8 ├── Makefile.in ├── install-sh ├── config.h.in ├── poundctl.c ├── FAQ ├── pound.h ├── pound.c ├── CHANGELOG ├── z2_2_5_1.py ├── GPL.txt └── pound.8 /poundctl.8: -------------------------------------------------------------------------------- 1 | .TH POUNDCTL "8" "Jan 2010" "poundctl" "System Manager's Manual" 2 | .SH NAME 3 | poundctl \- control the pound(8) daemon 4 | .SH SYNOPSIS 5 | .TP 6 | .B poundctl \fI-c /path/to/socket\fR [\fI-L/-l\fR] [\fI-S/-s\fR] [\fI-B/-b\fR] [\fI-N/-n\fR] [\fI-H\fR] [\fI-X\fR] 7 | .SH DESCRIPTION 8 | .PP 9 | .B Poundctl 10 | controls various aspects of the operation of the 11 | .I pound(8) 12 | program. 13 | .SH OPTIONS 14 | Options available: 15 | .TP 16 | \fB\-c /path/to/socket\fR 17 | The path to the (Unix-domain) socket 18 | .B Pound 19 | was configured to listen on for control. Your 20 | .B Pound 21 | configuration file must contain the directive 22 | .I Control "/path/to/socket" 23 | for 24 | .B poundctl 25 | to work. 26 | .TP 27 | \fB\-L/-l n\fR 28 | Enable/disable a listener. A disabled listener will stop accepting connection 29 | requests. 30 | .TP 31 | \fB\-S/-s n m\fR 32 | Enable/disable a service. A disabled service will not be used by 33 | .B Pound 34 | to answer requests. 35 | .TP 36 | \fB\-B/-b n m r\fR 37 | Enable/disable a back-end. A disabled back-end will not be passed requests to 38 | answer. Note however that existing sessions may still cause requests to be 39 | sent their way. 40 | .TP 41 | \fB\-N n m k r\fR 42 | Add a session to service m in listener n. The session key is k and it points to 43 | back-end r. 44 | .TP 45 | \fB\-n n m k\fR 46 | Remove a session from service m in listener n. The session key is k. 47 | .PP 48 | The parameters n, m and r refer to the number assigned to a particular listener, 49 | service and back-end in the listings. A listener number of -1 refers by convention 50 | to the global context. 51 | .TP 52 | \fB\-H\fR 53 | Try to resolve the addresses to symbolic names. Depending on your configuration, 54 | this may require an active DNS. 55 | .TP 56 | \fB\-X\fR 57 | Show the results in XML format. 58 | .PP 59 | When called without flags 60 | .B poundctl 61 | will print out a listing of the 62 | .B Pound 63 | internal state. 64 | .SH AUTHOR 65 | Written by Robert Segall, Apsis GmbH. 66 | .SH "REPORTING BUGS" 67 | Report bugs to . 68 | .SH COPYRIGHT 69 | Copyright \(co 2002-2010 Apsis GmbH. 70 | .br 71 | This is free software; see the source for copying conditions. There is NO 72 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 73 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # Pound - the reverse-proxy load-balancer 2 | # Copyright (C) 2002-2010 Apsis GmbH 3 | # 4 | # This file is part of Pound. 5 | # 6 | # Pound is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # Pound is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # Contact information: 20 | # Apsis GmbH 21 | # P.O.Box 22 | # 8707 Uetikon am See 23 | # Switzerland 24 | # EMail: roseg@apsis.ch 25 | 26 | CC=@PTHREAD_CC@ 27 | VERSION="@PACKAGE_VERSION@" 28 | C_SSL="@C_SSL@" 29 | C_T_RSA="@C_T_RSA@" 30 | C_MAXBUF="@C_MAXBUF@" 31 | C_OWNER="@C_OWNER@" 32 | C_GROUP="@C_GROUP@" 33 | C_SUPER="@C_SUPER@" 34 | C_CERT1L="@C_CERT1L@" 35 | 36 | CFLAGS=-DF_CONF=\"$(F_CONF)\" -DVERSION=\"${VERSION}\" -DC_SSL=\"${C_SSL}\" -DC_T_RSA=\"${C_T_RSA}\" \ 37 | -DC_MAXBUF=\"${C_MAXBUF}\" -DC_OWNER=\"${C_OWNER}\" -DC_GROUP=\"${C_GROUP}\" -DC_SUPER=\"${C_SUPER}\" \ 38 | -DC_CERT1L=\"${C_CERT1L}\" @CFLAGS@ @PTHREAD_CFLAGS@ @CPPFLAGS@ 39 | LIBS=@LIBS@ @PTHREAD_LIBS@ 40 | 41 | prefix=@prefix@ 42 | exec_prefix=@exec_prefix@ 43 | 44 | # Configuration file default; if none, look at config.c for default! 45 | F_CONF=@sysconfdir@/pound.cfg 46 | 47 | OBJS=pound.o http.o config.o svc.o 48 | 49 | all: pound poundctl pound.8 50 | 51 | pound: $(OBJS) 52 | ${CC} @LDFLAGS@ -o pound $(OBJS) $(LIBS) 53 | 54 | poundctl: poundctl.o 55 | ${CC} @LDFLAGS@ -o poundctl poundctl.o $(LIBS) 56 | 57 | dh512.h: 58 | openssl dhparam -5 -C -noout 512 > dh512.h 59 | 60 | dh1024.h: 61 | openssl dhparam -5 -C -noout 1024 > dh1024.h 62 | 63 | $(OBJS): pound.h config.h 64 | 65 | svc.o: svc.c dh512.h dh1024.h 66 | gcc ${CFLAGS} -c -o svc.o svc.c 67 | 68 | install: all 69 | @INSTALL@ -d ${DESTDIR}@sbindir@ 70 | @INSTALL@ -o @I_OWNER@ -g @I_GRP@ -m 555 pound ${DESTDIR}@sbindir@/pound 71 | @INSTALL@ -o @I_OWNER@ -g @I_GRP@ -m 555 poundctl ${DESTDIR}@sbindir@/poundctl 72 | @INSTALL@ -d ${DESTDIR}@mandir@/man8 73 | @INSTALL@ -o @I_OWNER@ -g @I_GRP@ -m 644 pound.8 ${DESTDIR}@mandir@/man8/pound.8 74 | @INSTALL@ -o @I_OWNER@ -g @I_GRP@ -m 644 poundctl.8 ${DESTDIR}@mandir@/man8/poundctl.8 75 | 76 | clean: 77 | rm -f pound $(OBJS) poundctl poundctl.o 78 | rm -f dh512.h dh1024.h 79 | 80 | distclean: clean 81 | -rm -f config.h config.log config.status Makefile 82 | 83 | uninstall: 84 | -rm -f @sbindir@/pound @sbindir@/poundctl @mandir@/man8/pound.8 @mandir@/cat8/pound.8 @mandir@/man8/poundctl.8 @mandir@/cat8/poundctl.8 85 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5 (mit/util/scripts/install.sh). 5 | # 6 | # Copyright 1991 by the Massachusetts Institute of Technology 7 | # 8 | # Permission to use, copy, modify, distribute, and sell this software and its 9 | # documentation for any purpose is hereby granted without fee, provided that 10 | # the above copyright notice appear in all copies and that both that 11 | # copyright notice and this permission notice appear in supporting 12 | # documentation, and that the name of M.I.T. not be used in advertising or 13 | # publicity pertaining to distribution of the software without specific, 14 | # written prior permission. M.I.T. makes no representations about the 15 | # suitability of this software for any purpose. It is provided "as is" 16 | # without express or implied warranty. 17 | # 18 | # Calling this script install-sh is preferred over install.sh, to prevent 19 | # `make' implicit rules from creating a file called install from it 20 | # when there is no Makefile. 21 | # 22 | # This script is compatible with the BSD install script, but was written 23 | # from scratch. It can only install one file at a time, a restriction 24 | # shared with many OS's install programs. 25 | 26 | 27 | # set DOITPROG to echo to test this script 28 | 29 | # Don't use :- since 4.3BSD and earlier shells don't like it. 30 | doit="${DOITPROG-}" 31 | 32 | 33 | # put in absolute paths if you don't have them in your path; or use env. vars. 34 | 35 | mvprog="${MVPROG-mv}" 36 | cpprog="${CPPROG-cp}" 37 | chmodprog="${CHMODPROG-chmod}" 38 | chownprog="${CHOWNPROG-chown}" 39 | chgrpprog="${CHGRPPROG-chgrp}" 40 | stripprog="${STRIPPROG-strip}" 41 | rmprog="${RMPROG-rm}" 42 | mkdirprog="${MKDIRPROG-mkdir}" 43 | 44 | transformbasename="" 45 | transform_arg="" 46 | instcmd="$mvprog" 47 | chmodcmd="$chmodprog 0755" 48 | chowncmd="" 49 | chgrpcmd="" 50 | stripcmd="" 51 | rmcmd="$rmprog -f" 52 | mvcmd="$mvprog" 53 | src="" 54 | dst="" 55 | dir_arg="" 56 | 57 | while [ x"$1" != x ]; do 58 | case $1 in 59 | -c) instcmd="$cpprog" 60 | shift 61 | continue;; 62 | 63 | -d) dir_arg=true 64 | shift 65 | continue;; 66 | 67 | -m) chmodcmd="$chmodprog $2" 68 | shift 69 | shift 70 | continue;; 71 | 72 | -o) chowncmd="$chownprog $2" 73 | shift 74 | shift 75 | continue;; 76 | 77 | -g) chgrpcmd="$chgrpprog $2" 78 | shift 79 | shift 80 | continue;; 81 | 82 | -s) stripcmd="$stripprog" 83 | shift 84 | continue;; 85 | 86 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87 | shift 88 | continue;; 89 | 90 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91 | shift 92 | continue;; 93 | 94 | *) if [ x"$src" = x ] 95 | then 96 | src=$1 97 | else 98 | # this colon is to work around a 386BSD /bin/sh bug 99 | : 100 | dst=$1 101 | fi 102 | shift 103 | continue;; 104 | esac 105 | done 106 | 107 | if [ x"$src" = x ] 108 | then 109 | echo "install: no input file specified" 110 | exit 1 111 | else 112 | true 113 | fi 114 | 115 | if [ x"$dir_arg" != x ]; then 116 | dst=$src 117 | src="" 118 | 119 | if [ -d $dst ]; then 120 | instcmd=: 121 | chmodcmd="" 122 | else 123 | instcmd=mkdir 124 | fi 125 | else 126 | 127 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 128 | # might cause directories to be created, which would be especially bad 129 | # if $src (and thus $dsttmp) contains '*'. 130 | 131 | if [ -f $src -o -d $src ] 132 | then 133 | true 134 | else 135 | echo "install: $src does not exist" 136 | exit 1 137 | fi 138 | 139 | if [ x"$dst" = x ] 140 | then 141 | echo "install: no destination specified" 142 | exit 1 143 | else 144 | true 145 | fi 146 | 147 | # If destination is a directory, append the input filename; if your system 148 | # does not like double slashes in filenames, you may need to add some logic 149 | 150 | if [ -d $dst ] 151 | then 152 | dst="$dst"/`basename $src` 153 | else 154 | true 155 | fi 156 | fi 157 | 158 | ## this sed command emulates the dirname command 159 | dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 160 | 161 | # Make sure that the destination directory exists. 162 | # this part is taken from Noah Friedman's mkinstalldirs script 163 | 164 | # Skip lots of stat calls in the usual case. 165 | if [ ! -d "$dstdir" ]; then 166 | defaultIFS=' 167 | ' 168 | IFS="${IFS-${defaultIFS}}" 169 | 170 | oIFS="${IFS}" 171 | # Some sh's can't handle IFS=/ for some reason. 172 | IFS='%' 173 | set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 174 | IFS="${oIFS}" 175 | 176 | pathcomp='' 177 | 178 | while [ $# -ne 0 ] ; do 179 | pathcomp="${pathcomp}${1}" 180 | shift 181 | 182 | if [ ! -d "${pathcomp}" ] ; 183 | then 184 | $mkdirprog "${pathcomp}" 185 | else 186 | true 187 | fi 188 | 189 | pathcomp="${pathcomp}/" 190 | done 191 | fi 192 | 193 | if [ x"$dir_arg" != x ] 194 | then 195 | $doit $instcmd $dst && 196 | 197 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 198 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 199 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 200 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 201 | else 202 | 203 | # If we're going to rename the final executable, determine the name now. 204 | 205 | if [ x"$transformarg" = x ] 206 | then 207 | dstfile=`basename $dst` 208 | else 209 | dstfile=`basename $dst $transformbasename | 210 | sed $transformarg`$transformbasename 211 | fi 212 | 213 | # don't allow the sed command to completely eliminate the filename 214 | 215 | if [ x"$dstfile" = x ] 216 | then 217 | dstfile=`basename $dst` 218 | else 219 | true 220 | fi 221 | 222 | # Make a temp file name in the proper directory. 223 | 224 | dsttmp=$dstdir/#inst.$$# 225 | 226 | # Move or copy the file name to the temp name 227 | 228 | $doit $instcmd $src $dsttmp && 229 | 230 | trap "rm -f ${dsttmp}" 0 && 231 | 232 | # and set any options; do chmod last to preserve setuid bits 233 | 234 | # If any of these fail, we abort the whole thing. If we want to 235 | # ignore errors from any of these, just make sure not to ignore 236 | # errors from the above "$doit $instcmd $src $dsttmp" command. 237 | 238 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 239 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 240 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 241 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 242 | 243 | # Now rename the file to the real destination. 244 | 245 | $doit $rmcmd -f $dstdir/$dstfile && 246 | $doit $mvcmd $dsttmp $dstdir/$dstfile 247 | 248 | fi && 249 | 250 | 251 | exit 0 252 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.in by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_ARPA_INET_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_CTYPE_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_ERRNO_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_FCNTL_H 14 | 15 | /* Define to 1 if you have the `fork' function. */ 16 | #undef HAVE_FORK 17 | 18 | /* Define to 1 if you have the `getaddrinfo' function. */ 19 | #undef HAVE_GETADDRINFO 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_GETOPT_H 23 | 24 | /* Define to 1 if you have the `gettimeofday' function. */ 25 | #undef HAVE_GETTIMEOFDAY 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_GRP_H 29 | 30 | /* Define to 1 if you have the `inet_ntop' function. */ 31 | #undef HAVE_INET_NTOP 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_INTTYPES_H 35 | 36 | /* Define to 1 if you have the `dl' library (-ldl). */ 37 | #undef HAVE_LIBDL 38 | 39 | /* Define if libpcreposix is available */ 40 | #undef HAVE_LIBPCREPOSIX 41 | 42 | /* Define to 1 if you have the `localtime_r' function. */ 43 | #undef HAVE_LOCALTIME_R 44 | 45 | /* Define to 1 if your system has a GNU libc compatible `malloc' function, and 46 | to 0 otherwise. */ 47 | #undef HAVE_MALLOC 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #undef HAVE_MEMORY_H 51 | 52 | /* Define to 1 if you have the `memset' function. */ 53 | #undef HAVE_MEMSET 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #undef HAVE_NETDB_H 57 | 58 | /* Define to 1 if you have the header file. */ 59 | #undef HAVE_NETINET_IN_H 60 | 61 | /* Define to 1 if you have the header file. */ 62 | #undef HAVE_NETINET_TCP_H 63 | 64 | /* Define to 1 if you have the header file. */ 65 | #undef HAVE_OPENSSL_ENGINE_H 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #undef HAVE_OPENSSL_SSL_H 69 | 70 | /* Define to 1 if you have the header file. */ 71 | #undef HAVE_PCREPOSIX_H 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #undef HAVE_PCRE_PCREPOSIX_H 75 | 76 | /* Define to 1 if you have the `poll' function. */ 77 | #undef HAVE_POLL 78 | 79 | /* Define if you have POSIX threads libraries and header files. */ 80 | #undef HAVE_PTHREAD 81 | 82 | /* Define to 1 if you have the header file. */ 83 | #undef HAVE_PTHREAD_H 84 | 85 | /* Define to 1 if you have the header file. */ 86 | #undef HAVE_PWD_H 87 | 88 | /* Define to 1 if you have the `regcomp' function. */ 89 | #undef HAVE_REGCOMP 90 | 91 | /* Define to 1 if you have the header file. */ 92 | #undef HAVE_REGEX_H 93 | 94 | /* Define to 1 if you have the `setsid' function. */ 95 | #undef HAVE_SETSID 96 | 97 | /* Define to 1 if you have the header file. */ 98 | #undef HAVE_SIGNAL_H 99 | 100 | /* Define to 1 if you have the `socket' function. */ 101 | #undef HAVE_SOCKET 102 | 103 | /* Define to 1 if `stat' has the bug that it succeeds when given the 104 | zero-length file name argument. */ 105 | #undef HAVE_STAT_EMPTY_STRING_BUG 106 | 107 | /* Define to 1 if you have the header file. */ 108 | #undef HAVE_STDARG_H 109 | 110 | /* Define to 1 if you have the header file. */ 111 | #undef HAVE_STDINT_H 112 | 113 | /* Define to 1 if you have the header file. */ 114 | #undef HAVE_STDLIB_H 115 | 116 | /* Define to 1 if you have the `strcasecmp' function. */ 117 | #undef HAVE_STRCASECMP 118 | 119 | /* Define to 1 if you have the `strchr' function. */ 120 | #undef HAVE_STRCHR 121 | 122 | /* Define to 1 if you have the `strdup' function. */ 123 | #undef HAVE_STRDUP 124 | 125 | /* Define to 1 if you have the `strerror' function. */ 126 | #undef HAVE_STRERROR 127 | 128 | /* Define to 1 if you have the `strftime' function. */ 129 | #undef HAVE_STRFTIME 130 | 131 | /* Define to 1 if you have the header file. */ 132 | #undef HAVE_STRINGS_H 133 | 134 | /* Define to 1 if you have the header file. */ 135 | #undef HAVE_STRING_H 136 | 137 | /* Define to 1 if you have the `strncasecmp' function. */ 138 | #undef HAVE_STRNCASECMP 139 | 140 | /* Define to 1 if you have the `strspn' function. */ 141 | #undef HAVE_STRSPN 142 | 143 | /* Define to 1 if you have the `strtol' function. */ 144 | #undef HAVE_STRTOL 145 | 146 | /* Define to 1 if you have the header file. */ 147 | #undef HAVE_SYS_POLL_H 148 | 149 | /* Define to 1 if you have the header file. */ 150 | #undef HAVE_SYS_SELECT_H 151 | 152 | /* Define to 1 if you have the header file. */ 153 | #undef HAVE_SYS_SOCKET_H 154 | 155 | /* Define to 1 if you have the header file. */ 156 | #undef HAVE_SYS_STAT_H 157 | 158 | /* Define to 1 if you have the header file. */ 159 | #undef HAVE_SYS_TIME_H 160 | 161 | /* Define to 1 if you have the header file. */ 162 | #undef HAVE_SYS_TYPES_H 163 | 164 | /* Define to 1 if you have the header file. */ 165 | #undef HAVE_SYS_UN_H 166 | 167 | /* Define to 1 if you have the header file. */ 168 | #undef HAVE_SYS_WAIT_H 169 | 170 | /* Define to 1 if you have the header file. */ 171 | #undef HAVE_TIME_H 172 | 173 | /* Define to 1 if you have the header file. */ 174 | #undef HAVE_UNISTD_H 175 | 176 | /* Define to 1 if you have the `vfork' function. */ 177 | #undef HAVE_VFORK 178 | 179 | /* Define to 1 if you have the header file. */ 180 | #undef HAVE_VFORK_H 181 | 182 | /* Define to 1 if you have the header file. */ 183 | #undef HAVE_WAIT_H 184 | 185 | /* Define to 1 if `fork' works. */ 186 | #undef HAVE_WORKING_FORK 187 | 188 | /* Define to 1 if `vfork' works. */ 189 | #undef HAVE_WORKING_VFORK 190 | 191 | /* Define to 1 if you have the `X509_STORE_set_flags' function. */ 192 | #undef HAVE_X509_STORE_SET_FLAGS 193 | 194 | /* Define to 1 if `lstat' dereferences a symlink specified with a trailing 195 | slash. */ 196 | #undef LSTAT_FOLLOWS_SLASHED_SYMLINK 197 | 198 | /* Define to the address where bug reports for this package should be sent. */ 199 | #undef PACKAGE_BUGREPORT 200 | 201 | /* Define to the full name of this package. */ 202 | #undef PACKAGE_NAME 203 | 204 | /* Define to the full name and version of this package. */ 205 | #undef PACKAGE_STRING 206 | 207 | /* Define to the one symbol short name of this package. */ 208 | #undef PACKAGE_TARNAME 209 | 210 | /* Define to the version of this package. */ 211 | #undef PACKAGE_VERSION 212 | 213 | /* Define to the necessary symbol if this constant uses a non-standard name on 214 | your system. */ 215 | #undef PTHREAD_CREATE_JOINABLE 216 | 217 | /* Define as the return type of signal handlers (`int' or `void'). */ 218 | #undef RETSIGTYPE 219 | 220 | /* Define to the type of arg 1 for `select'. */ 221 | #undef SELECT_TYPE_ARG1 222 | 223 | /* Define to the type of args 2, 3 and 4 for `select'. */ 224 | #undef SELECT_TYPE_ARG234 225 | 226 | /* Define to the type of arg 5 for `select'. */ 227 | #undef SELECT_TYPE_ARG5 228 | 229 | /* Define to 1 if you have the ANSI C header files. */ 230 | #undef STDC_HEADERS 231 | 232 | /* Define to 1 if you can safely include both and . */ 233 | #undef TIME_WITH_SYS_TIME 234 | 235 | /* Define to empty if `const' does not conform to ANSI C. */ 236 | #undef const 237 | 238 | /* Define to `int' if doesn't define. */ 239 | #undef gid_t 240 | 241 | /* Define to rpl_malloc if the replacement function should be used. */ 242 | #undef malloc 243 | 244 | /* Define to `int' if does not define. */ 245 | #undef pid_t 246 | 247 | /* Define to `int' if doesn't define. */ 248 | #undef uid_t 249 | 250 | /* Define as `fork' if `vfork' does not work. */ 251 | #undef vfork 252 | -------------------------------------------------------------------------------- /poundctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Pound - the reverse-proxy load-balancer 3 | * Copyright (C) 2002-2010 Apsis GmbH 4 | * 5 | * This file is part of Pound. 6 | * 7 | * Pound is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Pound is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * Contact information: 21 | * Apsis GmbH 22 | * P.O.Box 23 | * 8707 Uetikon am See 24 | * Switzerland 25 | * EMail: roseg@apsis.ch 26 | */ 27 | #define NO_EXTERNALS 1 28 | #include "pound.h" 29 | 30 | static int xml_out = 0; 31 | static int host_names = 0; 32 | 33 | static void 34 | usage(const char *arg0) 35 | { 36 | fprintf(stderr, "Usage: %s -c /control/socket [ -X ] cmd\n", arg0); 37 | fprintf(stderr, "\twhere cmd is one of:\n"); 38 | fprintf(stderr, "\t-L n - enable listener n\n"); 39 | fprintf(stderr, "\t-l n - disable listener n\n"); 40 | fprintf(stderr, "\t-S n m - enable service m in service n (use -1 for global services)\n"); 41 | fprintf(stderr, "\t-s n m - disable service m in service n (use -1 for global services)\n"); 42 | fprintf(stderr, "\t-B n m r - enable back-end r in service m in listener n\n"); 43 | fprintf(stderr, "\t-b n m r - disable back-end r in service m in listener n\n"); 44 | fprintf(stderr, "\t-N n m k r - add a session with key k and back-end r in service m in listener n\n"); 45 | fprintf(stderr, "\t-n n m k - remove a session with key k r in service m in listener n\n"); 46 | fprintf(stderr, "\n"); 47 | fprintf(stderr, "\tentering the command without arguments lists the current configuration.\n"); 48 | fprintf(stderr, "\tthe -X flag results in XML output.\n"); 49 | fprintf(stderr, "\tthe -H flag shows symbolic host names instead of addresses.\n"); 50 | exit(1); 51 | } 52 | 53 | /* 54 | * Translate inet/inet6 address/port into a string 55 | */ 56 | static char * 57 | prt_addr(const struct addrinfo *addr) 58 | { 59 | static char res[UNIX_PATH_MAX]; 60 | char buf[UNIX_PATH_MAX]; 61 | int port; 62 | void *src; 63 | 64 | memset(buf, 0, UNIX_PATH_MAX); 65 | #ifdef HAVE_INET_NTOP 66 | switch(addr->ai_family) { 67 | case AF_INET: 68 | src = (void *)&((struct sockaddr_in *)addr->ai_addr)->sin_addr.s_addr; 69 | port = ntohs(((struct sockaddr_in *)addr->ai_addr)->sin_port); 70 | if(host_names && !getnameinfo(addr->ai_addr, addr->ai_addrlen, buf, UNIX_PATH_MAX - 1, NULL, 0, 0)) 71 | break; 72 | if(inet_ntop(AF_INET, src, buf, UNIX_PATH_MAX - 1) == NULL) 73 | strncpy(buf, "(UNKNOWN)", UNIX_PATH_MAX - 1); 74 | break; 75 | case AF_INET6: 76 | src = (void *)&((struct sockaddr_in6 *)addr->ai_addr)->sin6_addr.s6_addr; 77 | port = ntohs(((struct sockaddr_in6 *)addr->ai_addr)->sin6_port); 78 | if(host_names && !getnameinfo(addr->ai_addr, addr->ai_addrlen, buf, UNIX_PATH_MAX - 1, NULL, 0, 0)) 79 | break; 80 | if(inet_ntop(AF_INET6, src, buf, UNIX_PATH_MAX - 1) == NULL) 81 | strncpy(buf, "(UNKNOWN)", UNIX_PATH_MAX - 1); 82 | break; 83 | case AF_UNIX: 84 | strncpy(buf, (char *)addr->ai_addr, UNIX_PATH_MAX - 1); 85 | port = 0; 86 | break; 87 | default: 88 | strncpy(buf, "(UNKNOWN)", UNIX_PATH_MAX - 1); 89 | port = 0; 90 | break; 91 | } 92 | snprintf(res, UNIX_PATH_MAX - 1, "%s:%d", buf, port); 93 | #else 94 | #error "Pound needs inet_ntop()" 95 | #endif 96 | return res; 97 | } 98 | 99 | static void 100 | be_prt(const int sock) 101 | { 102 | BACKEND be; 103 | struct sockaddr_storage a, h; 104 | int n_be; 105 | 106 | n_be = 0; 107 | while(read(sock, (void *)&be, sizeof(BACKEND)) == sizeof(BACKEND)) { 108 | if(be.disabled < 0) 109 | break; 110 | read(sock, &a, be.addr.ai_addrlen); 111 | be.addr.ai_addr = (struct sockaddr *)&a; 112 | if(be.ha_addr.ai_addrlen > 0) { 113 | read(sock, &h, be.ha_addr.ai_addrlen); 114 | be.ha_addr.ai_addr = (struct sockaddr *)&h; 115 | } 116 | if(xml_out) 117 | printf("\n", 118 | n_be++, 119 | prt_addr(&be.addr), be.t_average / 1000000, be.priority, be.alive? "yes": "DEAD", 120 | be.disabled? "DISABLED": "active"); 121 | else 122 | printf(" %3d. Backend %s %s (%d %.3f sec) %s\n", n_be++, prt_addr(&be.addr), 123 | be.disabled? "DISABLED": "active", be.priority, be.t_average / 1000000, be.alive? "alive": "DEAD"); 124 | } 125 | return; 126 | } 127 | 128 | static void 129 | sess_prt(const int sock) 130 | { 131 | TABNODE sess; 132 | int n_be, n_sess, cont_len; 133 | char buf[KEY_SIZE + 1], escaped[KEY_SIZE * 2 + 1]; 134 | 135 | n_sess = 0; 136 | while(read(sock, (void *)&sess, sizeof(TABNODE)) == sizeof(TABNODE)) { 137 | if(sess.content == NULL) 138 | break; 139 | read(sock, &n_be, sizeof(n_be)); 140 | read(sock, &cont_len, sizeof(cont_len)); 141 | memset(buf, 0, KEY_SIZE + 1); 142 | /* cont_len is at most KEY_SIZE */ 143 | read(sock, buf, cont_len); 144 | if(xml_out) { 145 | int i, j; 146 | char escaped[KEY_SIZE * 2 + 1]; 147 | 148 | for(i = j = 0; buf[i]; i++) 149 | if(buf[i] == '"') { 150 | escaped[j++] = '\\'; 151 | escaped[j++] = '"'; 152 | } else 153 | escaped[j++] = buf[i]; 154 | escaped[j] = '\0'; 155 | printf("\n", n_sess++, escaped, n_be); 156 | } else 157 | printf(" %3d. Session %s -> %d\n", n_sess++, buf, n_be); 158 | } 159 | return; 160 | } 161 | 162 | static void 163 | svc_prt(const int sock) 164 | { 165 | SERVICE svc; 166 | int n_svc; 167 | 168 | n_svc = 0; 169 | while(read(sock, (void *)&svc, sizeof(SERVICE)) == sizeof(SERVICE)) { 170 | if(svc.disabled < 0) 171 | break; 172 | if(xml_out) { 173 | if(svc.name[0]) 174 | printf("\n", 175 | n_svc++, svc.name, svc.disabled? "DISABLED": "active"); 176 | else 177 | printf("\n", n_svc++, svc.disabled? " DISABLED": ""); 178 | } else { 179 | if(svc.name[0]) 180 | printf(" %3d. Service \"%s\" %s (%d)\n", n_svc++, svc.name, svc.disabled? "DISABLED": "active", 181 | svc.tot_pri); 182 | else 183 | printf(" %3d. Service %s (%d)\n", n_svc++, svc.disabled? "DISABLED": "active", svc.tot_pri); 184 | } 185 | be_prt(sock); 186 | sess_prt(sock); 187 | if(xml_out) 188 | printf("\n"); 189 | } 190 | return; 191 | } 192 | 193 | static int 194 | get_sock(const char *sock_name) 195 | { 196 | struct sockaddr_un ctrl; 197 | int res; 198 | 199 | memset(&ctrl, 0, sizeof(ctrl)); 200 | ctrl.sun_family = AF_UNIX; 201 | strncpy(ctrl.sun_path, sock_name, sizeof(ctrl.sun_path) - 1); 202 | if((res = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { 203 | perror("socket create"); 204 | exit(1); 205 | } 206 | if(connect(res, (struct sockaddr *)&ctrl, (socklen_t)sizeof(ctrl)) < 0) { 207 | perror("connect"); 208 | exit(1); 209 | } 210 | return res; 211 | } 212 | 213 | main(const int argc, char **argv) 214 | { 215 | CTRL_CMD cmd; 216 | int sock, n_lstn, n_svc, n_be, n_sess, i; 217 | char *arg0, *sock_name, buf[KEY_SIZE + 1]; 218 | int c_opt, en_lst, de_lst, en_svc, de_svc, en_be, de_be, a_sess, d_sess, is_set; 219 | LISTENER lstn; 220 | SERVICE svc; 221 | BACKEND be; 222 | TABNODE sess; 223 | struct sockaddr_storage a; 224 | 225 | arg0 = *argv; 226 | sock_name = NULL; 227 | en_lst = de_lst = en_svc = de_svc = en_be = de_be = is_set = a_sess = d_sess = 0; 228 | memset(&cmd, 0, sizeof(cmd)); 229 | opterr = 0; 230 | i = 0; 231 | while(!i && (c_opt = getopt(argc, argv, "c:LlSsBbNnXH")) > 0) 232 | switch(c_opt) { 233 | case 'c': 234 | sock_name = optarg; 235 | break; 236 | case 'X': 237 | xml_out = 1; 238 | break; 239 | case 'L': 240 | if(is_set) 241 | usage(arg0); 242 | en_lst = is_set = 1; 243 | break; 244 | case 'l': 245 | if(is_set) 246 | usage(arg0); 247 | de_lst = is_set = 1; 248 | break; 249 | case 'S': 250 | if(is_set) 251 | usage(arg0); 252 | en_svc = is_set = 1; 253 | break; 254 | case 's': 255 | if(is_set) 256 | usage(arg0); 257 | de_svc = is_set = 1; 258 | break; 259 | case 'B': 260 | if(is_set) 261 | usage(arg0); 262 | en_be = is_set = 1; 263 | break; 264 | case 'b': 265 | if(is_set) 266 | usage(arg0); 267 | de_be = is_set = 1; 268 | break; 269 | case 'N': 270 | if(is_set) 271 | usage(arg0); 272 | a_sess = is_set = 1; 273 | break; 274 | case 'n': 275 | if(is_set) 276 | usage(arg0); 277 | d_sess = is_set = 1; 278 | break; 279 | case 'H': 280 | host_names = 1; 281 | break; 282 | default: 283 | if(optopt == '1') { 284 | optind--; 285 | i = 1; 286 | } else { 287 | fprintf(stderr, "bad flag -%c", optopt); 288 | usage(arg0); 289 | } 290 | break; 291 | } 292 | 293 | if(sock_name == NULL) 294 | usage(arg0); 295 | if(en_lst || de_lst) { 296 | if(optind != (argc - 1)) 297 | usage(arg0); 298 | cmd.cmd = (en_lst? CTRL_EN_LSTN: CTRL_DE_LSTN); 299 | cmd.listener = atoi(argv[optind++]); 300 | } 301 | if(en_svc || de_svc) { 302 | if(optind != (argc - 2)) 303 | usage(arg0); 304 | cmd.cmd = (en_svc? CTRL_EN_SVC: CTRL_DE_SVC); 305 | cmd.listener = atoi(argv[optind++]); 306 | cmd.service = atoi(argv[optind++]); 307 | } 308 | if(en_be || de_be) { 309 | if(optind != (argc - 3)) 310 | usage(arg0); 311 | cmd.cmd = (en_be? CTRL_EN_BE: CTRL_DE_BE); 312 | cmd.listener = atoi(argv[optind++]); 313 | cmd.service = atoi(argv[optind++]); 314 | cmd.backend = atoi(argv[optind++]); 315 | } 316 | if(a_sess) { 317 | if(optind != (argc - 4)) 318 | usage(arg0); 319 | cmd.cmd = CTRL_ADD_SESS; 320 | cmd.listener = atoi(argv[optind++]); 321 | cmd.service = atoi(argv[optind++]); 322 | memset(cmd.key, 0, KEY_SIZE + 1); 323 | strncpy(cmd.key, argv[optind++], KEY_SIZE); 324 | cmd.backend = atoi(argv[optind++]); 325 | } 326 | if(d_sess) { 327 | if(optind != (argc - 3)) 328 | usage(arg0); 329 | cmd.cmd = CTRL_DEL_SESS; 330 | cmd.listener = atoi(argv[optind++]); 331 | cmd.service = atoi(argv[optind++]); 332 | strncpy(cmd.key, argv[optind++], KEY_SIZE); 333 | } 334 | if(!is_set) { 335 | if(optind != argc) 336 | usage(arg0); 337 | cmd.cmd = CTRL_LST; 338 | } 339 | 340 | sock = get_sock(sock_name); 341 | write(sock, &cmd, sizeof(cmd)); 342 | 343 | if (!is_set) { 344 | n_lstn = 0; 345 | if(xml_out) 346 | printf("\n"); 347 | while(read(sock, (void *)&lstn, sizeof(LISTENER)) == sizeof(LISTENER)) { 348 | if(lstn.disabled < 0) 349 | break; 350 | read(sock, &a, lstn.addr.ai_addrlen); 351 | lstn.addr.ai_addr = (struct sockaddr *)&a; 352 | if(xml_out) 353 | printf("\n", 354 | n_lstn++, lstn.ctx? "HTTPS": "http", 355 | prt_addr(&lstn.addr), lstn.disabled? "DISABLED": "active"); 356 | else 357 | printf("%3d. %s Listener %s %s\n", n_lstn++, lstn.ctx? "HTTPS" : "http", 358 | prt_addr(&lstn.addr), lstn.disabled? "*D": "a"); 359 | svc_prt(sock); 360 | if(xml_out) 361 | printf("\n"); 362 | } 363 | if(!xml_out) 364 | printf(" -1. Global services\n"); 365 | svc_prt(sock); 366 | if(xml_out) 367 | printf("\n"); 368 | } 369 | return 0; 370 | } 371 | -------------------------------------------------------------------------------- /FAQ: -------------------------------------------------------------------------------- 1 | FREQUENTLY ASKED QUESTIONS 2 | 3 | 1. General 4 | ========== 5 | 6 | 1.1 Will Pound run my Web application? 7 | 8 | No. Pound is a proxy, not a Web server - it does not deliver content by 9 | itself. It is just the middle-man between a client and a server. 10 | 11 | 1.2 Will Pound make my server go faster? 12 | 13 | No. Pound is just a proxy - no caching of any kind takes place. Pound 14 | IS able to distribute requests between several back-end servers, thus 15 | allowing for faster overall response times, but it won't speed-up a 16 | single Web sever. 17 | 18 | 1.3 Will Pound make my server more secure? 19 | 20 | Probably yes. Pound has its own checks on the validity of HTTP requests 21 | and often catches malicious requests that are used to attack Web servers. 22 | 23 | 1.4 Can I use Pound to change/rewrite/redirect requests? 24 | 25 | No. Pound tries to be as transparent as possible - ideally a client 26 | should not be aware that there is anything between itself and the actual 27 | Web server. A limited form of redirects are available - see the man page. 28 | 29 | 1.5 Can I use Pound to deny certain requests? 30 | 31 | Yes. Pound has quite a good mechanism for classifying requests and it 32 | can deny/reject certain requests based on URL and/or header content. 33 | 34 | 35 | 2. Configuration, Compilation and Installation 36 | ============================================== 37 | 38 | 2.1 I try to compile and it fails on "needs OpenSSL with thread support" 39 | 40 | Pound is a multi-threaded program and it needs an OpenSSL library 41 | compiled with thread support (optional in the OpenSSL configuration and 42 | absent in some default installations, such as *BSD). If your default 43 | library does not support threads you must install a thread-enabled 44 | version. 45 | 46 | 2.2 Pound compiles correctly but crashes on *BSD 47 | 48 | On some of the newer versions of *BSD (FreeBSD 5.x, OpenBSD 3.x) the 49 | Pound autoconf may not correctly recognize the threading library. Add 50 | manually to the generated Makefile the option -DNEED_STACK in the 51 | CFLAGS. 52 | 53 | 2.3 I want to run Pound with daemon-tools but it goes to background 54 | 55 | You need to configure Pound for non-daemon operations: add "Daemon 0" 56 | to the config file. 57 | 58 | 2.4 Pound runs OK but some normal requests are rejected with "bad URL" 59 | 60 | Pound checks the requested URLs quite thoroughly and rejects malformed 61 | or illegal URLs - or at least illegal according to the RFCs. See the 62 | man page for details. 63 | 64 | 2.5 Pound runs OK but I get a "pthread_create" error message 65 | 66 | You may be hitting the system limit on the number of processes. On 67 | systems that implement threads as processes (as Linux does) you should 68 | make sure that the Pound process has permission to start a sufficient 69 | number of processes. 70 | 71 | In some rare cases you may be running into the system limit on the 72 | number of threads. Check your system details for the value of 73 | PTHREAD_THREADS_MAX. If needed you must recompile the threads library 74 | with a higher value. 75 | 76 | 2.6 What resources does Pound need/use? 77 | 78 | That depends very much on your system. On some systems, such as Linux 79 | and System V (AIX, HP-UX, etc), threads are implemented as processes, 80 | which means you must allow enough processes to run. On other systems, 81 | such as *BSD, where threads are implemented in user space (in-process), 82 | you should make sure that Pound can use sufficient memory for all the 83 | threads and that the process is allowed to use enough file descriptors 84 | (2 per active connection). Finally, on systems that implement threads 85 | natively, such as Solaris, you need to make sure that enough threads 86 | and open file descriptors are allowed. 87 | 88 | 2.7 Is NPTL supported? 89 | 90 | Theoretically Pound will work with any POSIX-compliant threads package. 91 | In practice some of the newer NPTL implementations still have some 92 | bugs. At least on Linux running Pound with LD_ASSUME_KERNEL=2.4.19 93 | may be helpful. 94 | 95 | 96 | 3. Virtual Hosts 97 | ================ 98 | 99 | 3.1 How do I redirect specific virtual hosts to specific back-ends? 100 | 101 | Make the virtual host mandatory in the UrlGroup. For example, to have 102 | all requests to www.a.com go to 192.168.0.10 and all requests for 103 | www.b.com go to 192.168.0.20, define 104 | 105 | Service 106 | HeadRequire "Host:.*www.a.com.*" 107 | BackEnd 108 | Address 192.168.0.10 109 | Port 80 110 | End 111 | End 112 | 113 | Service 114 | HeadRequire "Host:.*www.b.com.*" 115 | BackEnd 116 | Address 192.168.0.20 117 | Port 80 118 | End 119 | End 120 | 121 | in your config file. 122 | 123 | 3.2 How do I redirect requests to specific back-ends based on the client 124 | address? 125 | 126 | You can do it easier via the packet filter you use. If you insist on 127 | having Pound do it use a combination of port redirection and separate 128 | instances of Pound for each port. For example, assume you want intranet 129 | clients (on 192.168.100.0/24) to use the server at 192.168.1.10 and 130 | external clients go to 192.168.1.20. Do the following: 131 | 132 | - redirect requests from 192.168.100.0/24 to port 8080 133 | 134 | pf: rdr on rl0 from 192.168.100.0/24 to 192.168.100.1 port 80 \ 135 | -> localhost port 8080 136 | 137 | netfilter: iptables -t nat -A PREROUTING -p tcp \ 138 | -s 192.168.100.0/24 --dport 80 -i eth0 -j DNAT \ 139 | --to localhost:8080 140 | 141 | - redirect requests from anywhere else to port 8081 142 | 143 | pf: rdr on rl0 from any to 192.168.100.1 port 80 \ 144 | -> localhost port 8081 145 | 146 | netfilter: iptables -t nat -A PREROUTING -p tcp \ 147 | --dport 80 -i eth0 -j DNAT --to localhost:8081 148 | 149 | - have a Pound listener on port 8080 and sending the 150 | requests to 192.168.1.10 151 | 152 | - have a Pound listener on port 8081 and sending the 153 | requests to 192.168.1.20 154 | 155 | 3.3 What happens when my server replies with a redirect? 156 | 157 | Depending on configuration, Pound can watch for redirect replies from back-ends 158 | and change them to the correct address. In order for this to happen the 159 | following conditions must be met: 160 | 161 | - Pound has "Check30x 1" 162 | - the back-end replies with a redirect. The address of that URL resolves to 163 | the same address as the one Pound is listening on or the address of the 164 | back-end itself. 165 | 166 | This feature is commonly used when Pound serves as a HTTPS wrapper, 167 | as the backend redirect to "Location: http://x.y.com" is rewritten as 168 | "Location: https://x.y.com". 169 | 170 | 171 | 4. HTTPS 172 | ======== 173 | 174 | 4.1 Can I have Pound force HTTPS connections to certain URLs/back-ends? 175 | 176 | Yes - define a Service with a Redirect back-end. 177 | 178 | 4.2 How can I do virtual hosting with HTTPS? 179 | 180 | The simple answer is that neither you, nor anybody else can, due to a 181 | limitation of the HTTPS protocol. In its simplest form an HTTPS (SSL) 182 | connection goes through the following stages: 183 | 184 | - negotiation: the client contacts the server, receives a certificate 185 | from it, and negotiates the protocol details (cipher parameters, etc). 186 | 187 | - authentication: the client checks that the certificate received matches 188 | the server it wanted and validates that the certificate is correct as 189 | attested by some certificate authority. 190 | 191 | - request/response: normal HTTP, encrypted in transit. 192 | 193 | As you can see the certificate is sent before any request was received. 194 | Unfortunately, the first request specifies the virtual host that the 195 | client would like to talk to - and it may not match the server name in 196 | the certificate. 197 | 198 | 4.3 Pound does not start with message "can't read private key" 199 | 200 | The file you specify in the ListenHTTPS directive must contain both the 201 | server certificate and the private key to it in PEM format. See the man 202 | page for SSL_CTX_use_PrivateKey_file(3) for details. 203 | 204 | 4.4 How can a back-end know that the connection is via HTTPS? 205 | 206 | Pound can add a header for incoming requests indicating that they were 207 | received via HTTPS. See the details on AddHeader in the man page. 208 | 209 | 4.5 HTTPS connections fail when Pound runs chrooted 210 | 211 | The OpenSSL library requires access to /dev/urandom for its random seed. 212 | The normal device is not accessible in a jail root. You should add a 213 | link to the device to make it accessible. On Linux this would be: 214 | 215 | mknod /var/pound/dev/urandom c 1 9 216 | 217 | assuming that /var/pound is the root jail. 218 | 219 | 4.6 How can I force a back-end to generate the correct URL with HTTPS 220 | 221 | There is no simple answer to this question - each server and application 222 | have their own way of doing things. If your server does not use absolute 223 | paths then all is well - things will run out of the box. However if some 224 | frames, images, links or a base tag are generated with an absolute path 225 | you must find a way to force the generation with https://. 226 | 227 | 4.7 How can I find out about the client certificate in my application? 228 | 229 | For requests via HTTPS connections Pound can add the details of the 230 | client certificate as headers to each and every request it passes to 231 | the back-end. See the details on HTTPSHeaders in the man page. 232 | 233 | 4.8 Can Pound use my crypto accelerator hardware? 234 | 235 | Pound supports the OpenSSL engine architecture. If your crypto card is 236 | supported by OpenSSL then it is supported by Pound. See the SSLEngine 237 | directive in the man page. 238 | 239 | 4.9 Can Pound use HTTPS back-end servers? 240 | 241 | No, that is not supported: such a connection would break a lot of things, 242 | either security (Pound would effectively act as a man-in-the-middle, 243 | breaking the end-to-end integrity of SSL) or functionality (if Pound 244 | would just pass encrypted data back and forth things like session 245 | tracking and validity checking would be impossible). This means that 246 | such support is unlikely to ever be part of Pound. 247 | 248 | 249 | 5. Session tracking 250 | =================== 251 | 252 | 5.1 Can I have session tracking based on URL and/or Cookie? 253 | 254 | Pound can track sessions based on client IP address, a cookie, an URL 255 | parameter or BasicAuthentication. These options are mutually exclusive - 256 | only one of them can be used per UrlGroup. 257 | 258 | 5.2 When does a session expire? 259 | 260 | A session is kept for the specified number of seconds. If during this 261 | time no new request was received the session is discarded. 262 | 263 | 5.3 Does Pound create/track its own sessions? 264 | 265 | No. Pound does not add anything to the requests or the responses - it 266 | uses the tokens generated by the back-end servers exclusively. 267 | 268 | 269 | 6. Logging 270 | ========== 271 | 272 | 6.1 Can I use Webalizer on Pound log files? 273 | 274 | Yes. If you use LogLevel 3 or 4 Pound uses one of the standard log 275 | formats that are recognized by applications such as Webalizer. You will 276 | have to remove the time-stamp generated by the syslog - see cut(1) for 277 | details. 278 | 279 | 6.2 How do I log the original client address in the back-end log? 280 | 281 | Pound adds the X-Forwarded-for header with the original client address 282 | to every request. Use it for your logs on the back-end servers. 283 | 284 | 6.3 How can I separate the Pound log from other syslog messages? 285 | 286 | If you use the syslog facility you can configure it to send the pound 287 | messages to a separate file. You may want to separate by severity as 288 | well - normal log messages use LOG_INFO, everything else is not request 289 | information. See syslogd(8) for details on how to configure it. 290 | 291 | 6.4 How can I separate error messages from normal log messages? 292 | 293 | If you use syslog: normal requests are logged at LOG_INFO, everything 294 | else is higher. 295 | 296 | If you run without syslog: normal request logging to stdout, everything 297 | else to stderr. 298 | 299 | 6.5 Why does Pound not log anything when chrooted? 300 | 301 | On some systems you need access to /dev/log in order to use the syslog(8) 302 | facility. Create the device as needed in the root jail you use. 303 | 304 | 6.6 Why can't Pound log directly to a file? 305 | 306 | This is a security requirement. As things stand, Pound does not write at 307 | all to the disk. The existing tools - such as syslog - allow all the 308 | flexibility one could wish for. 309 | 310 | If you absolutely must you can try the patches from Shinji Tanaka (see 311 | http://www.hatena-inc.co.jp/~stanaka/pound/ for details). 312 | 313 | 314 | 7. WebDAV 315 | ========= 316 | 317 | 7.1 I compiled Pound with DAV support but it still rejects the requests 318 | 319 | You also need to define "WebDAV 1" in your config file, and (depending on 320 | your server or application) "xHTTP 1" as well. 321 | 322 | 7.3 Can I use Pound as a front-end for Subversion? 323 | 324 | Yes. You may have some problems with using it via HTTPS, but HTTP should 325 | work. 326 | 327 | 328 | 8. Zope 329 | ======= 330 | 331 | 8.1 What configurations is Pound most helpful for? 332 | 333 | If you have several servers running on top of a ZEO server, Pound will 334 | allow you to load-balance between them (BTW, this was the original 335 | motivation for developing Pound). Pound also makes for a very good, 336 | light-weight front-end for a single Zope - exposing the Zope Web-server 337 | directly on the big, bad Internet is not a very good idea. 338 | 339 | 8.2 Can I have virtual hosts in Zope without Apache? 340 | 341 | Yes. Despite persistent rumors, the Virtual Host Monster works perfectly 342 | well on its own (dark incantations at midnight under the shade of the 343 | cross-shaped oak branch are NOT required). All you need to do is to 344 | add a VHM in the Zope root, click on the Mappings tab and add whatever 345 | hosts you need. 346 | 347 | 8.3 Can I have HTTPS for Zope? 348 | 349 | Yes. Pound will happily pass SSL requests to Zope. You have three possible 350 | methods to force Zope to generate responses with the https:// prefix: 351 | 352 | - if all you need is a specific area to be accessible only through HTTPS 353 | you can add a SiteRoot with the correct name. 354 | 355 | - alternately the Pound distribution includes patches for z2.py that 356 | include a new -y flag for a "https://" port. 357 | 358 | - finally, for version 2.7 or later you can set it in zope.conf. 359 | 360 | 8.4 Can I force HTTPS for certain areas in Zope? 361 | 362 | Yes. Add a check for the SSL-specific headers in the dtml_header or 363 | whatever equivalent you use. See the details on HTTPSHeaders in the man 364 | page. 365 | 366 | 367 | 9. Miscellaneous/MS 368 | =================== 369 | 370 | 9.1 IE fails to connect to Pound via HTTPS 371 | 372 | Define the ciphers to be 373 | 374 | "ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL" 375 | 376 | in the config file. We have had reports of IE problems with other 377 | ciphers. 378 | 379 | 9.2 IE has big delays in getting replies from Pound 380 | 381 | Try a shorter Client timeout. IE uses exactly 4 sockets, and as long as 382 | they stay open it won't do anything else. A short Client value will 383 | force the socket(s) to be closed earlier, thus avoiding annoying waits. 384 | 385 | 9.3 I try to run MS OWA and Pound rejects the requests 386 | 387 | Make sure you configured Pound with --enable-msdav. Make sure you 388 | included "WebDAV 1" in the config file. Pray that MS would adhere to 389 | some known standard. Repeat as necessary. 390 | 391 | 9.4 How can I force OWA to accept HTTPS requests? 392 | 393 | Make sure to define 394 | 395 | AddHeader "Front-End-Https: on" 396 | 397 | in the config file. This will force OWA to generate the responses with 398 | the correct protocol. 399 | -------------------------------------------------------------------------------- /pound.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Pound - the reverse-proxy load-balancer 3 | * Copyright (C) 2002-2010 Apsis GmbH 4 | * 5 | * This file is part of Pound. 6 | * 7 | * Pound is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Pound is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * Contact information: 21 | * Apsis GmbH 22 | * P.O.Box 23 | * 8707 Uetikon am See 24 | * Switzerland 25 | * EMail: roseg@apsis.ch 26 | */ 27 | 28 | #include "config.h" 29 | #include 30 | #include 31 | 32 | #if HAVE_STDLIB_H 33 | #include 34 | #else 35 | #error "Pound needs stdlib.h" 36 | #endif 37 | 38 | #if HAVE_UNISTD_H 39 | #include 40 | #else 41 | #error "Pound needs unistd.h" 42 | #endif 43 | 44 | #if HAVE_GETOPT_H 45 | #include 46 | #endif 47 | 48 | #if HAVE_PTHREAD_H 49 | #include 50 | #else 51 | #error "Pound needs pthread.h" 52 | #endif 53 | 54 | #if HAVE_STRING_H 55 | #include 56 | #else 57 | #error "Pound needs string.h" 58 | #endif 59 | 60 | #if TIME_WITH_SYS_TIME 61 | #if HAVE_SYS_TIME_H 62 | #include 63 | #else 64 | #error "Pound needs sys/time.h" 65 | #endif 66 | #if HAVE_TIME_H 67 | #include 68 | #else 69 | #error "Pound needs time.h" 70 | #endif 71 | #else /* may not mix sys/time.h and time.h */ 72 | #if HAVE_SYS_TIME_H 73 | #include 74 | #elif HAVE_TIME_H 75 | #include 76 | #else 77 | #error "Pound needs time.h" 78 | #endif 79 | #endif /* mix */ 80 | 81 | #if HAVE_SYS_TYPES_H 82 | #include 83 | #else 84 | #error "Pound needs sys/types.h" 85 | #endif 86 | 87 | #if HAVE_SYS_SOCKET_H 88 | #include 89 | #else 90 | #error "Pound needs sys/socket.h" 91 | #endif 92 | 93 | #if HAVE_SYS_UN_H 94 | #include 95 | #else 96 | #error "Pound needs sys/un.h" 97 | #endif 98 | 99 | #ifndef UNIX_PATH_MAX 100 | /* on Linux this is defined in linux/un.h rather than sys/un.h - go figure */ 101 | #define UNIX_PATH_MAX 108 102 | #endif 103 | 104 | #if HAVE_NETINET_IN_H 105 | #include 106 | #else 107 | #error "Pound needs netinet/in.h" 108 | #endif 109 | 110 | #if HAVE_NETINET_TCP_H 111 | #include 112 | #else 113 | #error "Pound needs netinet/tcp.h" 114 | #endif 115 | 116 | #if HAVE_ARPA_INET_H 117 | #include 118 | #else 119 | #error "Pound needs arpa/inet.h" 120 | #endif 121 | 122 | #if HAVE_NETDB_H 123 | #include 124 | #else 125 | #error "Pound needs netdb.h" 126 | #endif 127 | 128 | #if HAVE_SYS_POLL_H 129 | #include 130 | #else 131 | #error "Pound needs sys/poll.h" 132 | #endif 133 | 134 | #if HAVE_OPENSSL_SSL_H 135 | #define OPENSSL_THREAD_DEFINES 136 | #include 137 | #include 138 | #include 139 | #if OPENSSL_VERSION_NUMBER >= 0x00907000L 140 | #ifndef OPENSSL_THREADS 141 | #error "Pound requires OpenSSL with thread support" 142 | #endif 143 | #else 144 | #ifndef THREADS 145 | #error "Pound requires OpenSSL with thread support" 146 | #endif 147 | #endif 148 | #else 149 | #error "Pound needs openssl/ssl.h" 150 | #endif 151 | 152 | #if HAVE_OPENSSL_ENGINE_H 153 | #include 154 | #endif 155 | 156 | #if HAVE_PWD_H 157 | #include 158 | #else 159 | #error "Pound needs pwd.h" 160 | #endif 161 | 162 | #if HAVE_GRP_H 163 | #include 164 | #else 165 | #error "Pound needs grp.h" 166 | #endif 167 | 168 | #if HAVE_SYSLOG_H 169 | #include 170 | #endif 171 | 172 | #if HAVE_SYS_SYSLOG_H 173 | #include 174 | #endif 175 | 176 | #if HAVE_SIGNAL_H 177 | #include 178 | #else 179 | #error "Pound needs signal.h" 180 | #endif 181 | 182 | #if HAVE_LIBPCREPOSIX 183 | #if HAVE_PCREPOSIX_H 184 | #include 185 | #elif HAVE_PCRE_PCREPOSIX 186 | #include 187 | #else 188 | #error "You have libpcreposix, but the header files are missing. Use --disable-pcreposix" 189 | #endif 190 | #elif HAVE_REGEX_H 191 | #include 192 | #else 193 | #error "Pound needs regex.h" 194 | #endif 195 | 196 | #if HAVE_CTYPE_H 197 | #include 198 | #else 199 | #error "Pound needs ctype.h" 200 | #endif 201 | 202 | #if HAVE_ERRNO_H 203 | #include 204 | #else 205 | #error "Pound needs errno.h" 206 | #endif 207 | 208 | #if HAVE_WAIT_H 209 | #include 210 | #elif HAVE_SYS_WAIT_H 211 | #include 212 | #else 213 | #error "Pound needs sys/wait.h" 214 | #endif 215 | 216 | #if HAVE_SYS_STAT_H 217 | #include 218 | #else 219 | #error "Pound needs sys/stat.h" 220 | #endif 221 | 222 | #if HAVE_FCNTL_H 223 | #include 224 | #else 225 | #error "Pound needs fcntl.h" 226 | #endif 227 | 228 | #if HAVE_STDARG_H 229 | #include 230 | #else 231 | #include 232 | #endif 233 | 234 | #ifndef __STDC__ 235 | #define const 236 | #endif 237 | 238 | #ifndef NO_EXTERNALS 239 | /* 240 | * Global variables needed by everybody 241 | */ 242 | 243 | extern char *user, /* user to run as */ 244 | *group, /* group to run as */ 245 | *root_jail, /* directory to chroot to */ 246 | *pid_name, /* file to record pid in */ 247 | *ctrl_name; /* control socket name */ 248 | 249 | extern int alive_to, /* check interval for resurrection */ 250 | daemonize, /* run as daemon */ 251 | log_facility, /* log facility to use */ 252 | print_log, /* print log messages to stdout/stderr */ 253 | grace, /* grace period before shutdown */ 254 | control_sock; /* control socket */ 255 | 256 | extern regex_t HEADER, /* Allowed header */ 257 | CHUNK_HEAD, /* chunk header line */ 258 | RESP_SKIP, /* responses for which we skip response */ 259 | RESP_IGN, /* responses for which we ignore content */ 260 | LOCATION, /* the host we are redirected to */ 261 | AUTHORIZATION; /* the Authorisation header */ 262 | 263 | #ifndef SOL_TCP 264 | /* for systems without the definition */ 265 | extern int SOL_TCP; 266 | #endif 267 | 268 | #endif /* NO_EXTERNALS */ 269 | 270 | #ifndef MAXBUF 271 | #define MAXBUF 4096 272 | #endif 273 | 274 | #define MAXHEADERS 128 275 | 276 | #ifndef F_CONF 277 | #define F_CONF "/usr/local/etc/pound.cfg" 278 | #endif 279 | 280 | #ifndef F_PID 281 | #define F_PID "/var/run/pound.pid" 282 | #endif 283 | 284 | /* matcher chain */ 285 | typedef struct _matcher { 286 | regex_t pat; /* pattern to match the request/header against */ 287 | struct _matcher *next; 288 | } MATCHER; 289 | 290 | /* back-end types */ 291 | typedef enum { SESS_NONE, SESS_IP, SESS_COOKIE, SESS_URL, SESS_PARM, SESS_HEADER, SESS_BASIC } SESS_TYPE; 292 | 293 | /* back-end definition */ 294 | typedef struct _backend { 295 | int be_type; /* 0 if real back-end, otherwise code (301, 302/default, 307) */ 296 | struct addrinfo addr; /* IPv4/6 address */ 297 | int priority; /* priority */ 298 | int to; /* read/write time-out */ 299 | int conn_to; /* connection time-out */ 300 | struct addrinfo ha_addr; /* HA address/port */ 301 | char *url; /* for redirectors */ 302 | int redir_req; /* the redirect should include the request path */ 303 | SSL_CTX *ctx; /* CTX for SSL connections */ 304 | pthread_mutex_t mut; /* mutex for this back-end */ 305 | int n_requests; /* number of requests seen */ 306 | double t_requests; /* time to answer these requests */ 307 | double t_average; /* average time to answer requests */ 308 | int alive; /* false if the back-end is dead */ 309 | int resurrect; /* this back-end is to be resurrected */ 310 | int disabled; /* true if the back-end is disabled */ 311 | struct _backend *next; 312 | } BACKEND; 313 | 314 | typedef struct _tn { 315 | char *key; 316 | void *content; 317 | time_t last_acc; 318 | } TABNODE; 319 | 320 | #define n_children(N) ((N)? (N)->children: 0) 321 | 322 | /* maximal session key size */ 323 | #define KEY_SIZE 127 324 | 325 | /* service definition */ 326 | typedef struct _service { 327 | char name[KEY_SIZE + 1]; /* symbolic name */ 328 | MATCHER *url, /* request matcher */ 329 | *req_head, /* required headers */ 330 | *deny_head; /* forbidden headers */ 331 | BACKEND *backends; 332 | BACKEND *emergency; 333 | int abs_pri; /* abs total priority for all back-ends */ 334 | int tot_pri; /* total priority for current back-ends */ 335 | pthread_mutex_t mut; /* mutex for this service */ 336 | SESS_TYPE sess_type; 337 | int sess_ttl; /* session time-to-live */ 338 | regex_t sess_start; /* pattern to identify the session data */ 339 | regex_t sess_pat; /* pattern to match the session data */ 340 | LHASH *sessions; /* currently active sessions */ 341 | int dynscale; /* true if the back-ends should be dynamically rescaled */ 342 | int disabled; /* true if the service is disabled */ 343 | struct _service *next; 344 | } SERVICE; 345 | 346 | #ifndef NO_EXTERNALS 347 | extern SERVICE *services; /* global services (if any) */ 348 | #endif /* NO_EXTERNALS */ 349 | 350 | /* Listener definition */ 351 | typedef struct _listener { 352 | struct addrinfo addr; /* IPv4/6 address */ 353 | int sock; /* listening socket */ 354 | SSL_CTX *ctx; /* CTX for SSL connections */ 355 | int clnt_check; /* client verification mode */ 356 | int noHTTPS11; /* HTTP 1.1 mode for SSL */ 357 | char *add_head; /* extra SSL header */ 358 | regex_t verb; /* pattern to match the request verb against */ 359 | int to; /* client time-out */ 360 | int has_pat; /* was a URL pattern defined? */ 361 | regex_t url_pat; /* pattern to match the request URL against */ 362 | char *err414, /* error messages */ 363 | *err500, 364 | *err501, 365 | *err503; 366 | long max_req; /* max. request size */ 367 | MATCHER *head_off; /* headers to remove */ 368 | int rewr_loc; /* rewrite location response */ 369 | int rewr_dest; /* rewrite destination header */ 370 | int disabled; /* true if the listener is disabled */ 371 | int log_level; /* log level for this listener */ 372 | SERVICE *services; 373 | struct _listener *next; 374 | } LISTENER; 375 | 376 | #ifndef NO_EXTERNALS 377 | extern LISTENER *listeners; /* all available listeners */ 378 | #endif /* NO_EXTERNALS */ 379 | 380 | typedef struct { 381 | int sock; 382 | LISTENER *lstn; 383 | struct addrinfo from_host; 384 | } thr_arg; /* argument to processing threads: socket, origin */ 385 | 386 | /* Header types */ 387 | #define HEADER_ILLEGAL -1 388 | #define HEADER_OTHER 0 389 | #define HEADER_TRANSFER_ENCODING 1 390 | #define HEADER_CONTENT_LENGTH 2 391 | #define HEADER_CONNECTION 3 392 | #define HEADER_LOCATION 4 393 | #define HEADER_CONTLOCATION 5 394 | #define HEADER_HOST 6 395 | #define HEADER_REFERER 7 396 | #define HEADER_USER_AGENT 8 397 | #define HEADER_URI 9 398 | #define HEADER_DESTINATION 10 399 | 400 | /* control request stuff */ 401 | typedef enum { 402 | CTRL_LST, 403 | CTRL_EN_LSTN, CTRL_DE_LSTN, 404 | CTRL_EN_SVC, CTRL_DE_SVC, 405 | CTRL_EN_BE, CTRL_DE_BE, 406 | CTRL_ADD_SESS, CTRL_DEL_SESS 407 | } CTRL_CODE; 408 | 409 | typedef struct { 410 | CTRL_CODE cmd; 411 | int listener; 412 | int service; 413 | int backend; 414 | char key[KEY_SIZE + 1]; 415 | } CTRL_CMD; 416 | 417 | #ifdef NEED_INADDRT 418 | /* for oldish Unices - normally this is in /usr/include/netinet/in.h */ 419 | typedef u_int32_t in_addr_t; 420 | #endif 421 | 422 | #ifdef NEED_INPORTT 423 | /* for oldish Unices - normally this is in /usr/include/netinet/in.h */ 424 | typedef u_int16_t in_port_t; 425 | #endif 426 | 427 | #ifdef NEED_TIMET 428 | /* for oldish Unices - normally this is in /usr/include/time.h */ 429 | typedef u_int32_t time_t; 430 | #endif 431 | 432 | /* 433 | * handle an HTTP request 434 | */ 435 | extern void *thr_http(void *); 436 | 437 | /* 438 | * Log an error to the syslog or to stderr 439 | */ 440 | extern void logmsg(const int, const char *, ...); 441 | 442 | /* 443 | * Translate inet/inet6 address into a string 444 | */ 445 | extern void addr2str(char *, const int, const struct addrinfo *, const int); 446 | 447 | /* 448 | * Return a string representation for a back-end address 449 | */ 450 | #define str_be(BUF, LEN, BE) addr2str((BUF), (LEN), &(BE)->addr, 0) 451 | 452 | /* 453 | * Find the right service for a request 454 | */ 455 | extern SERVICE *get_service(const LISTENER *, const char *, char **const); 456 | 457 | /* 458 | * Find the right back-end for a request 459 | */ 460 | extern BACKEND *get_backend(SERVICE *const, const struct addrinfo *, const char *, char **const); 461 | 462 | /* 463 | * Search for a host name, return the addrinfo for it 464 | */ 465 | extern int get_host(char *const, struct addrinfo *); 466 | 467 | /* 468 | * Find if a redirect needs rewriting 469 | * In general we have two possibilities that require it: 470 | * (1) if the redirect was done to the correct location with the wrong protocol 471 | * (2) if the redirect was done to the back-end rather than the listener 472 | */ 473 | extern int need_rewrite(const int, char *const, char *const, const LISTENER *, const BACKEND *); 474 | /* 475 | * (for cookies only) possibly create session based on response headers 476 | */ 477 | extern void upd_session(SERVICE *const, char **const, BACKEND *const); 478 | 479 | /* 480 | * Parse a header 481 | */ 482 | extern int check_header(const char *, char *); 483 | 484 | #define BE_DISABLE -1 485 | #define BE_KILL 1 486 | #define BE_ENABLE 0 487 | /* 488 | * mark a backend host as dead; 489 | * do nothing if no resurection code is active 490 | */ 491 | extern void kill_be(SERVICE *const, const BACKEND *, const int); 492 | 493 | /* 494 | * Rescale back-end priorities if needed 495 | * runs every 5 minutes 496 | */ 497 | #ifndef RESCALE_TO 498 | #define RESCALE_TO 300 499 | #endif 500 | 501 | /* 502 | * Dynamic rescaling constants 503 | */ 504 | #define RESCALE_MAX 32000 505 | #define RESCALE_MIN 8000 506 | #define RESCALE_BOT 4000 507 | 508 | /* 509 | * Update the number of requests and time to answer for a given back-end 510 | */ 511 | extern void upd_be(SERVICE *const svc, BACKEND *const be, const double); 512 | 513 | /* 514 | * Non-blocking version of connect(2). Does the same as connect(2) but 515 | * ensures it will time-out after a much shorter time period CONN_TO. 516 | */ 517 | extern int connect_nb(const int, const struct addrinfo *, const int); 518 | 519 | /* 520 | * Parse arguments/config file 521 | */ 522 | extern void config_parse(const int, char **const); 523 | 524 | /* 525 | * RSA ephemeral keys: how many and how often 526 | */ 527 | #define N_RSA_KEYS 11 528 | #ifndef T_RSA_KEYS 529 | #define T_RSA_KEYS 1800 530 | #endif 531 | 532 | /* 533 | * return a pre-generated RSA key 534 | */ 535 | extern RSA *RSA_tmp_callback(SSL *, int, int); 536 | 537 | /* 538 | * return a pre-generated RSA key 539 | */ 540 | extern DH *DH_tmp_callback(SSL *, int, int); 541 | 542 | /* 543 | * expiration stuff 544 | */ 545 | #ifndef EXPIRE_TO 546 | #define EXPIRE_TO 60 547 | #endif 548 | 549 | #ifndef HOST_TO 550 | #define HOST_TO 300 551 | #endif 552 | 553 | /* 554 | * initialise the timer functions: 555 | * - host_mut 556 | * - RSA_mut and keys 557 | */ 558 | extern void init_timer(void); 559 | 560 | /* 561 | * run timed functions: 562 | * - RSAgen every T_RSA_KEYS seconds 563 | * - rescale every RESCALE_TO seconds 564 | * - resurrect every alive_to seconds 565 | * - expire every EXPIRE_TO seconds 566 | */ 567 | extern void *thr_timer(void *); 568 | 569 | /* 570 | * The controlling thread 571 | * listens to client requests and calls the appropriate functions 572 | */ 573 | extern void *thr_control(void *); 574 | -------------------------------------------------------------------------------- /pound.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Pound - the reverse-proxy load-balancer 3 | * Copyright (C) 2002-2010 Apsis GmbH 4 | * 5 | * This file is part of Pound. 6 | * 7 | * Pound is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Pound is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * Contact information: 21 | * Apsis GmbH 22 | * P.O.Box 23 | * 8707 Uetikon am See 24 | * Switzerland 25 | * EMail: roseg@apsis.ch 26 | */ 27 | 28 | #include "pound.h" 29 | 30 | /* common variables */ 31 | char *user, /* user to run as */ 32 | *group, /* group to run as */ 33 | *root_jail, /* directory to chroot to */ 34 | *pid_name, /* file to record pid in */ 35 | *ctrl_name; /* control socket name */ 36 | 37 | int alive_to, /* check interval for resurrection */ 38 | daemonize, /* run as daemon */ 39 | log_facility, /* log facility to use */ 40 | print_log, /* print log messages to stdout/stderr */ 41 | grace, /* grace period before shutdown */ 42 | control_sock; /* control socket */ 43 | 44 | SERVICE *services; /* global services (if any) */ 45 | 46 | LISTENER *listeners; /* all available listeners */ 47 | 48 | regex_t HEADER, /* Allowed header */ 49 | CHUNK_HEAD, /* chunk header line */ 50 | RESP_SKIP, /* responses for which we skip response */ 51 | RESP_IGN, /* responses for which we ignore content */ 52 | LOCATION, /* the host we are redirected to */ 53 | AUTHORIZATION; /* the Authorisation header */ 54 | 55 | static int shut_down = 0; 56 | 57 | #ifndef SOL_TCP 58 | /* for systems without the definition */ 59 | int SOL_TCP; 60 | #endif 61 | 62 | /* worker pid */ 63 | static pid_t son = 0; 64 | 65 | /* 66 | * OpenSSL thread support stuff 67 | */ 68 | static pthread_mutex_t *l_array; 69 | 70 | static void 71 | l_init(void) 72 | { 73 | int i, n_locks; 74 | 75 | n_locks = CRYPTO_num_locks(); 76 | if((l_array = (pthread_mutex_t *)calloc(n_locks, sizeof(pthread_mutex_t))) == NULL) { 77 | logmsg(LOG_ERR, "lock init: out of memory - aborted..."); 78 | exit(1); 79 | } 80 | for(i = 0; i < n_locks; i++) 81 | /* pthread_mutex_init() always returns 0 */ 82 | pthread_mutex_init(&l_array[i], NULL); 83 | return; 84 | } 85 | 86 | static void 87 | l_lock(const int mode, const int n, /* unused */ const char *file, /* unused */ int line) 88 | { 89 | int ret_val; 90 | 91 | if(mode & CRYPTO_LOCK) { 92 | if(ret_val = pthread_mutex_lock(&l_array[n])) 93 | logmsg(LOG_ERR, "l_lock lock(): %s", strerror(ret_val)); 94 | } else { 95 | if(ret_val = pthread_mutex_unlock(&l_array[n])) 96 | logmsg(LOG_ERR, "l_lock unlock(): %s", strerror(ret_val)); 97 | } 98 | return; 99 | } 100 | 101 | static unsigned long 102 | l_id(void) 103 | { 104 | return (unsigned long)pthread_self(); 105 | } 106 | 107 | /* 108 | * handle SIGTERM/SIGQUIT - exit 109 | */ 110 | static RETSIGTYPE 111 | h_term(const int sig) 112 | { 113 | logmsg(LOG_NOTICE, "received signal %d - exiting...", sig); 114 | if(son > 0) 115 | kill(son, sig); 116 | if(ctrl_name != NULL) 117 | (void)unlink(ctrl_name); 118 | exit(0); 119 | } 120 | 121 | /* 122 | * handle SIGHUP/SIGINT - exit after grace period 123 | */ 124 | static RETSIGTYPE 125 | h_shut(const int sig) 126 | { 127 | int status; 128 | LISTENER *lstn; 129 | 130 | logmsg(LOG_NOTICE, "received signal %d - shutting down...", sig); 131 | if(son > 0) { 132 | for(lstn = listeners; lstn; lstn = lstn->next) 133 | close(lstn->sock); 134 | kill(son, sig); 135 | (void)wait(&status); 136 | if(ctrl_name != NULL) 137 | (void)unlink(ctrl_name); 138 | exit(0); 139 | } else 140 | shut_down = 1; 141 | } 142 | 143 | /* 144 | * Pound: the reverse-proxy/load-balancer 145 | * 146 | * Arguments: 147 | * -f config_file configuration file - exclusive of other flags 148 | */ 149 | 150 | int 151 | main(const int argc, char **argv) 152 | { 153 | int n_listeners, i, clnt_length, clnt; 154 | struct pollfd *polls; 155 | LISTENER *lstn; 156 | pthread_t thr; 157 | pthread_attr_t attr; 158 | struct sched_param sp; 159 | uid_t user_id; 160 | gid_t group_id; 161 | FILE *fpid; 162 | struct sockaddr_storage clnt_addr; 163 | char tmp[MAXBUF]; 164 | #ifndef SOL_TCP 165 | struct protoent *pe; 166 | #endif 167 | 168 | print_log = 0; 169 | (void)umask(077); 170 | control_sock = -1; 171 | log_facility = -1; 172 | logmsg(LOG_NOTICE, "starting..."); 173 | 174 | signal(SIGHUP, h_shut); 175 | signal(SIGINT, h_shut); 176 | signal(SIGTERM, h_term); 177 | signal(SIGQUIT, h_term); 178 | signal(SIGPIPE, SIG_IGN); 179 | 180 | srandom(getpid()); 181 | 182 | /* SSL stuff */ 183 | SSL_load_error_strings(); 184 | SSL_library_init(); 185 | OpenSSL_add_all_algorithms(); 186 | l_init(); 187 | CRYPTO_set_id_callback(l_id); 188 | CRYPTO_set_locking_callback(l_lock); 189 | init_timer(); 190 | 191 | /* prepare regular expressions */ 192 | if(regcomp(&HEADER, "^([a-z0-9!#$%&'*+.^_`|~-]+):[ \t]*(.*)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED) 193 | || regcomp(&CHUNK_HEAD, "^([0-9a-f]+).*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED) 194 | || regcomp(&RESP_SKIP, "^HTTP/1.1 100.*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED) 195 | || regcomp(&RESP_IGN, "^HTTP/1.[01] (10[1-9]|1[1-9][0-9]|204|30[456]).*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED) 196 | || regcomp(&LOCATION, "(http|https)://([^/]+)(.*)", REG_ICASE | REG_NEWLINE | REG_EXTENDED) 197 | || regcomp(&AUTHORIZATION, "Authorization:[ \t]*Basic[ \t]*([^ \t]*)[ \t]*", REG_ICASE | REG_NEWLINE | REG_EXTENDED) 198 | ) { 199 | logmsg(LOG_ERR, "bad essential Regex - aborted"); 200 | exit(1); 201 | } 202 | 203 | #ifndef SOL_TCP 204 | /* for systems without the definition */ 205 | if((pe = getprotobyname("tcp")) == NULL) { 206 | logmsg(LOG_ERR, "missing TCP protocol"); 207 | exit(1); 208 | } 209 | SOL_TCP = pe->p_proto; 210 | #endif 211 | 212 | /* read config */ 213 | config_parse(argc, argv); 214 | 215 | if(log_facility != -1) 216 | openlog("pound", LOG_CONS | LOG_NDELAY, LOG_DAEMON); 217 | if(ctrl_name != NULL) { 218 | struct sockaddr_un ctrl; 219 | 220 | memset(&ctrl, 0, sizeof(ctrl)); 221 | ctrl.sun_family = AF_UNIX; 222 | strncpy(ctrl.sun_path, ctrl_name, sizeof(ctrl.sun_path) - 1); 223 | (void)unlink(ctrl.sun_path); 224 | if((control_sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { 225 | logmsg(LOG_ERR, "Control \"%s\" create: %s", ctrl.sun_path, strerror(errno)); 226 | exit(1); 227 | } 228 | if(bind(control_sock, (struct sockaddr *)&ctrl, (socklen_t)sizeof(ctrl)) < 0) { 229 | logmsg(LOG_ERR, "Control \"%s\" bind: %s", ctrl.sun_path, strerror(errno)); 230 | exit(1); 231 | } 232 | listen(control_sock, 512); 233 | } 234 | 235 | /* open listeners */ 236 | for(lstn = listeners, n_listeners = 0; lstn; lstn = lstn->next, n_listeners++) { 237 | int opt; 238 | 239 | /* prepare the socket */ 240 | if((lstn->sock = socket(lstn->addr.ai_family == AF_INET? PF_INET: PF_INET6, SOCK_STREAM, 0)) < 0) { 241 | addr2str(tmp, MAXBUF - 1, &lstn->addr, 0); 242 | logmsg(LOG_ERR, "HTTP socket %s create: %s - aborted", tmp, strerror(errno)); 243 | exit(1); 244 | } 245 | opt = 1; 246 | setsockopt(lstn->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof(opt)); 247 | if(bind(lstn->sock, lstn->addr.ai_addr, (socklen_t)lstn->addr.ai_addrlen) < 0) { 248 | addr2str(tmp, MAXBUF - 1, &lstn->addr, 0); 249 | logmsg(LOG_ERR, "HTTP socket bind %s: %s - aborted", tmp, strerror(errno)); 250 | exit(1); 251 | } 252 | listen(lstn->sock, 512); 253 | } 254 | 255 | /* alloc the poll structures */ 256 | if((polls = (struct pollfd *)calloc(n_listeners, sizeof(struct pollfd))) == NULL) { 257 | logmsg(LOG_ERR, "Out of memory for poll - aborted"); 258 | exit(1); 259 | } 260 | for(lstn = listeners, i = 0; lstn; lstn = lstn->next, i++) 261 | polls[i].fd = lstn->sock; 262 | 263 | /* set uid if necessary */ 264 | if(user) { 265 | struct passwd *pw; 266 | 267 | if((pw = getpwnam(user)) == NULL) { 268 | logmsg(LOG_ERR, "no such user %s - aborted", user); 269 | exit(1); 270 | } 271 | user_id = pw->pw_uid; 272 | } 273 | 274 | /* set gid if necessary */ 275 | if(group) { 276 | struct group *gr; 277 | 278 | if((gr = getgrnam(group)) == NULL) { 279 | logmsg(LOG_ERR, "no such group %s - aborted", group); 280 | exit(1); 281 | } 282 | group_id = gr->gr_gid; 283 | } 284 | 285 | /* Turn off verbose messages (if necessary) */ 286 | print_log = 0; 287 | 288 | if(daemonize) { 289 | /* daemonize - make ourselves a subprocess. */ 290 | switch (fork()) { 291 | case 0: 292 | if(log_facility != -1) { 293 | close(0); 294 | close(1); 295 | close(2); 296 | } 297 | break; 298 | case -1: 299 | logmsg(LOG_ERR, "fork: %s - aborted", strerror(errno)); 300 | exit(1); 301 | default: 302 | exit(0); 303 | } 304 | #ifdef HAVE_SETSID 305 | (void) setsid(); 306 | #endif 307 | } 308 | 309 | /* record pid in file */ 310 | if((fpid = fopen(pid_name, "wt")) != NULL) { 311 | fprintf(fpid, "%d\n", getpid()); 312 | fclose(fpid); 313 | } else 314 | logmsg(LOG_NOTICE, "Create \"%s\": %s", pid_name, strerror(errno)); 315 | 316 | /* chroot if necessary */ 317 | if(root_jail) { 318 | if(chroot(root_jail)) { 319 | logmsg(LOG_ERR, "chroot: %s - aborted", strerror(errno)); 320 | exit(1); 321 | } 322 | if(chdir("/")) { 323 | logmsg(LOG_ERR, "chroot/chdir: %s - aborted", strerror(errno)); 324 | exit(1); 325 | } 326 | } 327 | 328 | if(group) 329 | if(setgid(group_id) || setegid(group_id)) { 330 | logmsg(LOG_ERR, "setgid: %s - aborted", strerror(errno)); 331 | exit(1); 332 | } 333 | if(user) 334 | if(setuid(user_id) || seteuid(user_id)) { 335 | logmsg(LOG_ERR, "setuid: %s - aborted", strerror(errno)); 336 | exit(1); 337 | } 338 | 339 | /* split off into monitor and working process if necessary */ 340 | for(;;) { 341 | #ifdef UPER 342 | if((son = fork()) > 0) { 343 | int status; 344 | 345 | (void)wait(&status); 346 | if(WIFEXITED(status)) 347 | logmsg(LOG_ERR, "MONITOR: worker exited normally %d, restarting...", WEXITSTATUS(status)); 348 | else if(WIFSIGNALED(status)) 349 | logmsg(LOG_ERR, "MONITOR: worker exited on signal %d, restarting...", WTERMSIG(status)); 350 | else 351 | logmsg(LOG_ERR, "MONITOR: worker exited (stopped?) %d, restarting...", status); 352 | } else if (son == 0) { 353 | #endif 354 | 355 | /* thread stuff */ 356 | pthread_attr_init(&attr); 357 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 358 | 359 | #ifdef NEED_STACK 360 | /* set new stack size - necessary for OpenBSD/FreeBSD and Linux NPTL */ 361 | if(pthread_attr_setstacksize(&attr, 1 << 18)) { 362 | logmsg(LOG_ERR, "can't set stack size - aborted"); 363 | exit(1); 364 | } 365 | #endif 366 | /* start timer */ 367 | if(pthread_create(&thr, &attr, thr_timer, NULL)) { 368 | logmsg(LOG_ERR, "create thr_resurect: %s - aborted", strerror(errno)); 369 | exit(1); 370 | } 371 | 372 | /* start the controlling thread (if needed) */ 373 | if(control_sock >= 0 && pthread_create(&thr, &attr, thr_control, NULL)) { 374 | logmsg(LOG_ERR, "create thr_control: %s - aborted", strerror(errno)); 375 | exit(1); 376 | } 377 | 378 | /* pause to make sure the service threads were started */ 379 | sleep(2); 380 | 381 | /* and start working */ 382 | for(;;) { 383 | if(shut_down) { 384 | logmsg(LOG_NOTICE, "shutting down..."); 385 | for(lstn = listeners; lstn; lstn = lstn->next) 386 | close(lstn->sock); 387 | if(grace > 0) { 388 | sleep(grace); 389 | logmsg(LOG_NOTICE, "grace period expired - exiting..."); 390 | } 391 | if(ctrl_name != NULL) 392 | (void)unlink(ctrl_name); 393 | exit(0); 394 | } 395 | for(lstn = listeners, i = 0; i < n_listeners; lstn = lstn->next, i++) { 396 | polls[i].events = POLLIN | POLLPRI; 397 | polls[i].revents = 0; 398 | } 399 | if(poll(polls, n_listeners, -1) < 0) { 400 | logmsg(LOG_WARNING, "poll: %s", strerror(errno)); 401 | } else { 402 | for(lstn = listeners, i = 0; lstn; lstn = lstn->next, i++) { 403 | if(polls[i].revents & (POLLIN | POLLPRI)) { 404 | memset(&clnt_addr, 0, sizeof(clnt_addr)); 405 | clnt_length = sizeof(clnt_addr); 406 | if((clnt = accept(lstn->sock, (struct sockaddr *)&clnt_addr, 407 | (socklen_t *)&clnt_length)) < 0) { 408 | logmsg(LOG_WARNING, "HTTP accept: %s", strerror(errno)); 409 | } else if(((struct sockaddr_in *)&clnt_addr)->sin_family == AF_INET 410 | || ((struct sockaddr_in *)&clnt_addr)->sin_family == AF_INET6) { 411 | thr_arg *arg; 412 | 413 | if(lstn->disabled) { 414 | /* 415 | addr2str(tmp, MAXBUF - 1, &clnt_addr, 1); 416 | logmsg(LOG_WARNING, "HTTP disabled listener from %s", tmp); 417 | */ 418 | close(clnt); 419 | } 420 | if((arg = (thr_arg *)malloc(sizeof(thr_arg))) == NULL) { 421 | logmsg(LOG_WARNING, "HTTP arg: malloc"); 422 | close(clnt); 423 | continue; 424 | } 425 | arg->sock = clnt; 426 | arg->lstn = lstn; 427 | if((arg->from_host.ai_addr = (struct sockaddr *)malloc(clnt_length)) == NULL) { 428 | logmsg(LOG_WARNING, "HTTP arg address: malloc"); 429 | free(arg); 430 | continue; 431 | } 432 | memcpy(arg->from_host.ai_addr, &clnt_addr, clnt_length); 433 | arg->from_host.ai_addrlen = clnt_length; 434 | if(((struct sockaddr_in *)&clnt_addr)->sin_family == AF_INET) 435 | arg->from_host.ai_family = AF_INET; 436 | else 437 | arg->from_host.ai_family = AF_INET6; 438 | if(pthread_create(&thr, &attr, thr_http, (void *)arg)) { 439 | logmsg(LOG_WARNING, "HTTP pthread_create: %s", strerror(errno)); 440 | free(arg->from_host.ai_addr); 441 | free(arg); 442 | close(clnt); 443 | } 444 | } else { 445 | /* may happen on FreeBSD, I am told */ 446 | logmsg(LOG_WARNING, "HTTP connection prematurely closed by peer"); 447 | close(clnt); 448 | } 449 | } 450 | } 451 | } 452 | } 453 | #ifdef UPER 454 | } else { 455 | /* failed to spawn son */ 456 | logmsg(LOG_ERR, "Can't fork worker (%s) - aborted", strerror(errno)); 457 | exit(1); 458 | } 459 | #endif 460 | } 461 | } 462 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------ 2 | r67 | roseg | 2010-02-02 12:49:00 +0100 (Tue, 02 Feb 2010) | 9 lines 3 | 4 | Release 2.5 5 | 6 | Enhancements: 7 | 8 | Bug fixes: 9 | - fixed XML format to avoid problems with brain-dead parsers 10 | - fixed Redirect to accept "/" as a path, so that "Redirect http://x/" is 11 | considered an absolute path, but "Redirect http://x" is not 12 | 13 | ------------------------------------------------------------------------ 14 | r66 | roseg | 2010-01-04 17:20:55 +0100 (Mon, 04 Jan 2010) | 7 lines 15 | 16 | Release 2.5e 17 | 18 | Enhancements: 19 | - added support for symbolic host names in poundctl 20 | 21 | Bug fixes: 22 | 23 | ------------------------------------------------------------------------ 24 | r65 | roseg | 2009-12-07 17:01:21 +0100 (Mon, 07 Dec 2009) | 9 lines 25 | 26 | Release 2.5d 27 | 28 | Enhancements: 29 | - added support for --disable-pcreposix, --disable--tcmalloc, --disable-hoard in configuration script 30 | 31 | Bug fixes: 32 | - fixed problem with long input lines in http.c 33 | - if libpcreposix is present, then pcreposix.h must also be present 34 | 35 | ------------------------------------------------------------------------ 36 | r64 | roseg | 2009-09-21 13:16:57 +0200 (Mon, 21 Sep 2009) | 8 lines 37 | 38 | Release 2.5c 39 | 40 | Enhancements: 41 | - added support for HTTPS backends 42 | 43 | Bug fixes: 44 | - fixed problem with sub-patterns in session parameters 45 | 46 | ------------------------------------------------------------------------ 47 | r63 | roseg | 2009-08-19 17:44:07 +0200 (Wed, 19 Aug 2009) | 10 lines 48 | 49 | Release 2.5b 50 | 51 | Enhancements: 52 | - support for ConnTO directive 53 | - support for IgnoreCase directive 54 | 55 | Bug fixes: 56 | - fixed problem in conf_fgets (\n confuses the regexp) 57 | - changed RSA ephemeral keys regeneration default time (every 30 minutes) 58 | 59 | ------------------------------------------------------------------------ 60 | r62 | roseg | 2009-08-06 17:23:30 +0200 (Thu, 06 Aug 2009) | 9 lines 61 | 62 | Release 2.5a 63 | 64 | Enhancements: 65 | - support for include directive 66 | 67 | Bug fixes: 68 | - fixed generation of ephemeral RSA keys (avoid premature locking) 69 | - added pre-generated DH parameters 70 | 71 | ------------------------------------------------------------------------ 72 | r61 | roseg | 2009-06-29 17:53:55 +0200 (Mon, 29 Jun 2009) | 13 lines 73 | 74 | Release 2.4.5 75 | 76 | Stable release 2.4.5 77 | 78 | Enhancements: 79 | - log back-end killed/disabled/enabled (thanks to Joe Gooch and Jon Garvin) 80 | - kill a BE on connection failure only if it has no HAport defined (thanks to Albert); the request may still fail! 81 | 82 | Bug fixes: 83 | - fixed parantheses problems in need_rewrite (thanks to SBR) 84 | - added call to free_headers in http.c (thanks to SBR) 85 | - fixed maximal path length in UNIX domain sockets (thanks to Ricardo Gameiro) 86 | 87 | ------------------------------------------------------------------------ 88 | r60 | roseg | 2009-01-14 17:39:52 +0100 (Wed, 14 Jan 2009) | 18 lines 89 | 90 | Release 2.4.4 91 | 92 | Stable release 2.4.4 93 | 94 | Enhancements: 95 | - added support for UNSUBSCRIBE and NOTIFY in xHTTP 3 and 4 96 | - added support for BPROPFIND in xHTTP 4 97 | - on SSL connections always pass the cipher used to the back-end (thanks to Magnus Sandin) 98 | 99 | Bug fixes: 100 | - save and restore errno value in cur_time() (thanks to Albert) 101 | - fixed problem in timer thread (thanks to Albert) 102 | - added shutdown for failed socket connection (thanks to Albert) 103 | - fixed problem with CC containing spaces in Makefile.in (thanks to Elan Ruusamäe) 104 | - increased MAXBUF to default 4096 105 | - increased T_RSA default to 30 minutes 106 | - fixed a problem with Unix sockets back-ends (thanks to Ricardo Gameiro) 107 | 108 | ------------------------------------------------------------------------ 109 | r59 | roseg | 2008-05-31 12:25:41 +0200 (Sat, 31 May 2008) | 11 lines 110 | 111 | Release 2.4.3 112 | 113 | Stable release 2.4.3 114 | 115 | Enhancements: 116 | 117 | Bug fixes: 118 | - fixed problem in session access time updating (thanks to Piotr Jakubowski) 119 | - fixed problem in session removal (thanks to Doriam Mori) 120 | - fixed problem in Redirect logging (thanks to Albert) 121 | 122 | ------------------------------------------------------------------------ 123 | r58 | roseg | 2008-04-24 16:31:28 +0200 (Thu, 24 Apr 2008) | 13 lines 124 | 125 | Release 2.4.2 126 | 127 | Stable release 2.4.2 128 | 129 | Enhancements: 130 | 131 | Bug fixes: 132 | - fixed problem with session TTL -1 (thanks to Scott Royston for pointing it out) 133 | - fixed problem with back-end killing on failed connect 134 | - fixed a small problem in the poundctl XML output (thanks to johnlr for the fix) 135 | - added hints in call to getaddrinfo() (for Solaris 10 support) 136 | - fixed redirection problem (missing slash in Location/Content-location) 137 | 138 | ------------------------------------------------------------------------ 139 | r57 | roseg | 2008-04-05 11:45:41 +0200 (Sat, 05 Apr 2008) | 12 lines 140 | 141 | Release 2.4.1 142 | 143 | Stable release 2.4.1 144 | 145 | Enhancements: 146 | - added cache control for errors (thanks to Pavel Merdin for the suggestion) 147 | 148 | Bug fixes: 149 | - fixed problem with double slash in header rewriting (thanks to Cédric P.) 150 | - remove sched_policy to avoid problems on systems with poor support for it 151 | - fixed memory corruption problem with HAport 152 | 153 | ------------------------------------------------------------------------ 154 | r56 | roseg | 2008-02-11 12:53:51 +0100 (Mon, 11 Feb 2008) | 4 lines 155 | 156 | Release 2.4 157 | 158 | Stable release 2.4 159 | 160 | ------------------------------------------------------------------------ 161 | r55 | roseg | 2007-12-27 12:54:32 +0100 (Thu, 27 Dec 2007) | 7 lines 162 | 163 | Release 2.4f 164 | 165 | Enhancements: 166 | 167 | Bug fixes: 168 | - fixed back-end enable/disable (priority computing) 169 | 170 | ------------------------------------------------------------------------ 171 | r54 | roseg | 2007-11-29 18:16:36 +0100 (Thu, 29 Nov 2007) | 12 lines 172 | 173 | Enhancements: 174 | - added PARM session type. Old PARM is now URL 175 | - allow AddHeader for HTTP listeners as well 176 | - allow -1 for session (all types) TTL. Will hash the key to a fixed value 177 | - Redirect takes an optional code parameter (301, 302/default or 307) 178 | - new config param to allow printing the SSL certificate in a single line 179 | - new config param to control the maximal size of the input line 180 | - added better error messages for SSL loading problems 181 | 182 | Bug fixes: 183 | - if the same cookie is defined more than once use LAST definition 184 | 185 | ------------------------------------------------------------------------ 186 | r53 | roseg | 2007-08-15 18:26:58 +0200 (Wed, 15 Aug 2007) | 10 lines 187 | 188 | Release 2.4d 189 | 190 | Enhancements: 191 | - moved to GPLv3 192 | - now using lh_hash for the session tables 193 | 194 | Bug fixes: 195 | - allow case-sensitive matching for URLs 196 | - fixed memory leak in DNS searches 197 | 198 | ------------------------------------------------------------------------ 199 | r52 | roseg | 2007-07-04 15:29:27 +0200 (Wed, 04 Jul 2007) | 10 lines 200 | 201 | Release 2.4c 202 | 203 | Enhancements: 204 | - added XML output for poundctl 205 | - added more detailed error messages 206 | 207 | Bug fixes: 208 | - fixed problems with extra-long lines 209 | - fixed problems with chunked encoding 210 | 211 | ------------------------------------------------------------------------ 212 | r51 | roseg | 2007-05-18 10:35:02 +0200 (Fri, 18 May 2007) | 11 lines 213 | 214 | Release 2.4b 215 | 216 | Enhancements: 217 | - cleaned resurrection code 218 | - added RR threads scheduling 219 | 220 | Bug fixes: 221 | - fixed problem long lines (thanks to Rune Saetre) 222 | - fixed pcreposix autoconf for systems that also require pcre 223 | - fixed problem with IP session handling 224 | 225 | ------------------------------------------------------------------------ 226 | r49 | roseg | 2007-04-30 15:01:17 +0200 (Mon, 30 Apr 2007) | 11 lines 227 | 228 | Release 2.4a 229 | 230 | Enhancements: 231 | - added display of configuration switches 232 | - added grace period for shutdown (based on an idea from Rune Saetre) 233 | - added support for IPv6 (but host caching was removed) 234 | 235 | Bug fixes: 236 | - fixed test for owner/group (BSD portability) 237 | - fixed problem with premature opening of control socket 238 | 239 | ------------------------------------------------------------------------ 240 | r46 | roseg | 2007-04-11 15:00:11 +0200 (Wed, 11 Apr 2007) | 8 lines 241 | 242 | Release 2.3 243 | 244 | Enhancements: 245 | - added display of configuration switches 246 | - added grace period for shutdown (based on an idea from Rune Saetre) 247 | 248 | Bug fixes: 249 | 250 | ------------------------------------------------------------------------ 251 | r45 | roseg | 2007-04-04 18:15:53 +0200 (Wed, 04 Apr 2007) | 8 lines 252 | 253 | Release 2.2.8 254 | 255 | Enhancements: 256 | - more tweaking of the dynamic rescaling code 257 | - more information in poundctl printout 258 | 259 | Bug fixes: 260 | 261 | ------------------------------------------------------------------------ 262 | r44 | roseg | 2007-03-12 18:12:14 +0100 (Mon, 12 Mar 2007) | 8 lines 263 | 264 | Release 2.2.7 265 | 266 | Enhancements: 267 | - dynamic scaling is now a configuration directive (DynScale) 268 | - added vhost to LogLevel 5 269 | 270 | Bug fixes: 271 | 272 | ------------------------------------------------------------------------ 273 | r43 | roseg | 2007-03-02 10:30:01 +0100 (Fri, 02 Mar 2007) | 11 lines 274 | 275 | Release 2.2.6 276 | 277 | Enhancements: 278 | - added transaction time to LogLevel 5 279 | - added priority display for poundctl 280 | 281 | Bug fixes: 282 | - fixed problem when adding session via poundctl 283 | - fixed problem in session dump to poundctl 284 | - fixed problem in kill_be call to t_clean 285 | 286 | ------------------------------------------------------------------------ 287 | r42 | roseg | 2007-02-19 18:19:22 +0100 (Mon, 19 Feb 2007) | 7 lines 288 | 289 | Release 2.2.5 290 | 291 | Enhancements: 292 | 293 | Bug fixes: 294 | - fixed problem with sessions (BACKEND copying) 295 | 296 | ------------------------------------------------------------------------ 297 | r41 | roseg | 2007-02-10 15:26:42 +0100 (Sat, 10 Feb 2007) | 14 lines 298 | 299 | Release 2.2.4 300 | 301 | Enhancements: 302 | - modular tree library 303 | - consolidated all timed functions into a single thread 304 | - added gethostbyname cache 305 | - added LogLevel 5 - same as 4 but with service name and back-end information (thanks to Joe Gooch for the suggestion) 306 | - added session creation and removal to poundctl 307 | 308 | Bug fixes: 309 | - added LOG_NDELAY to openlog() 310 | - accept and immediately close connections to disabled listeners (thanks to Joe Gooch for the suggestion) 311 | - fixed problem with -1 values in poundctl 312 | 313 | ------------------------------------------------------------------------ 314 | r40 | roseg | 2007-01-19 21:29:07 +0100 (Fri, 19 Jan 2007) | 5 lines 315 | 316 | Release 2.2.3 317 | 318 | Bug fixes: 319 | - fixed problems in bad 2.2 release 320 | 321 | ------------------------------------------------------------------------ 322 | r39 | roseg | 2007-01-15 18:17:48 +0100 (Mon, 15 Jan 2007) | 13 lines 323 | 324 | Release 2.2.2 325 | 326 | Enhancements: 327 | - changes in the dynamic rescaling 328 | - doubled the session key size (for those people with insanely long cookies) 329 | - added LogFacility - for logging to stdout/stderr 330 | - added optional Service names 331 | 332 | Bug fixes: 333 | - fixed bug in multiple HeadRemove matching 334 | - fixed problem with extra large session keys 335 | - fixed problem for OpenBSD accept (blocks all threads) 336 | 337 | ------------------------------------------------------------------------ 338 | r38 | roseg | 2007-01-03 18:25:30 +0100 (Wed, 03 Jan 2007) | 13 lines 339 | 340 | Release 2.2.1 341 | 342 | Enhancements: 343 | - allow specific Listeners to override the gloabl LogLevel value 344 | - allow a default Client value to be defined at the global level 345 | - allow a default TimeOut value to be defined at the global level 346 | - added compile-time flags for file owner and group 347 | 348 | Bug fixes: 349 | - fixed some problems in the installation procedure 350 | - fixed problem in SSL session string 351 | - added protocol check in need_rewrite 352 | 353 | ------------------------------------------------------------------------ 354 | r37 | roseg | 2006-12-16 10:18:38 +0100 (Sat, 16 Dec 2006) | 45 lines 355 | 356 | Release 2.2 357 | 358 | Enhancements: 359 | - added the host to LogLevel 2 (if available) 360 | - added support for tcmalloc (from the Google perftools package) 361 | 362 | Bug fixes: 363 | - fixed problem with the initialisation of host_mut 364 | 365 | ***************************** 366 | Cumulative changes since 2.1: 367 | ***************************** 368 | 369 | Enhancements: 370 | - added dynamic rescaling of back-end priorities, compile-time flag to enable/disable it 371 | - added support for emergency back-ends 372 | - the program poundctl(8) is now available, added the Control configuration directive 373 | - SESS_IP now behaves like other session types (no longer sticky) 374 | - added RewriteLocation 2: rewrite location if it points to same address, but ignore port 375 | - Redirect uses the original request path 376 | - added RewriteDestination configuration flag to enable rewriting the Destination header 377 | - removed msdav compile-time configuration flag and MSDAV configuration flag, extended xHTTP to allow for 378 | WebDAV, MS-DAV and MS-RPC 379 | - added CRLlist directive, split CRL from CA 380 | - Error replies are sent as pure HTML 381 | - split error messages into: 382 | - LOG_ERR: errors (mostly fatal) 383 | - LOG_WARNING: errors (non-fatal) 384 | - LOG_NOTICE: problems 385 | - LOG_INFO: extra information 386 | - time to serve the requests is logged in LogLevel 2 387 | - added the (virtual) host to LogLevel 2 (if available) 388 | - added line numbers to config error messages 389 | - added TCP_NODELAY for faster response times 390 | - added support for tcmalloc (from the Google perftools package) 391 | 392 | Bug fixes: 393 | - fixed problem in str_be (evident mostly in LogLevel 2) 394 | - added 'const' wherever necessary 395 | - check for errors in mutex handling 396 | - fixed the verb pattern in HTTPS listeners 397 | - content is now ignored only on HEAD requests 398 | - fixed problems with autoconf on some systems 399 | - fixed problem with the initialisation of host_mut 400 | 401 | ------------------------------------------------------------------------ 402 | r36 | roseg | 2006-12-09 09:39:23 +0100 (Sat, 09 Dec 2006) | 6 lines 403 | 404 | Release 2.1.8 405 | 406 | Bug fixes: 407 | - fixed another small problem with autoconf on some systems 408 | - added support for systems that don't define SOL_TCP 409 | 410 | ------------------------------------------------------------------------ 411 | r35 | roseg | 2006-12-06 18:32:16 +0100 (Wed, 06 Dec 2006) | 10 lines 412 | 413 | Release 2.1.7 414 | 415 | Enhancements: 416 | - added TCP_NODELAY for faster response times 417 | - added compile-time flag to enable/disable dynamic priorities rescaling 418 | 419 | Bug fixes: 420 | - fixed problems with autoconf on some systems 421 | - fixed error in control function (be instead of svc) 422 | 423 | ------------------------------------------------------------------------ 424 | r34 | roseg | 2006-11-04 11:28:53 +0100 (Sat, 04 Nov 2006) | 9 lines 425 | 426 | Release 2.1.6 427 | 428 | Enhancements: 429 | - Redirect uses the original request path 430 | 431 | Bug fixes: 432 | - improved dynamic priorities calculation 433 | - fixed problem with Emergency back-ends 434 | 435 | ------------------------------------------------------------------------ 436 | r33 | roseg | 2006-10-23 09:24:28 +0200 (Mon, 23 Oct 2006) | 12 lines 437 | 438 | Release 2.1.5 439 | 440 | Enhancements: 441 | - added line numbers to config error messages 442 | - added dynamic rescaling of back-end priorities 443 | - added support for emergency back-ends 444 | - the program poundctl(8) is now available 445 | - added the Control configuration directive 446 | 447 | Bug fixes: 448 | - improved owner/group detection for install 449 | 450 | ------------------------------------------------------------------------ 451 | r32 | roseg | 2006-10-14 16:39:29 +0200 (Sat, 14 Oct 2006) | 6 lines 452 | 453 | Release 2.1.4 454 | 455 | Bug fixes: 456 | - content is now ignored only on HEAD requests 457 | - added CRLlist directive, split CRL from CA 458 | 459 | ------------------------------------------------------------------------ 460 | r31 | roseg | 2006-09-21 18:41:15 +0200 (Thu, 21 Sep 2006) | 6 lines 461 | 462 | Release 2.1.3 463 | 464 | Bug fixes: 465 | - fixed the verb pattern in HTTPS listeners 466 | - removed the spurious printf in cur_time 467 | 468 | ------------------------------------------------------------------------ 469 | r30 | roseg | 2006-09-18 18:12:16 +0200 (Mon, 18 Sep 2006) | 18 lines 470 | 471 | Release 2.1.2 472 | 473 | Enhancements: 474 | - Error replies are sent as pure HTML 475 | - split error messages into: 476 | - LOG_ERR: errors (mostly fatal) 477 | - LOG_WARNING: errors (non-fatal) 478 | - LOG_NOTICE: problems 479 | - LOG_INFO: extra information 480 | - removed msdav compile-time configuration flag 481 | - removed MSDAV configuration flag 482 | - extended xHTTP to allow for WebDAV, MS-DAV and MS-RPC 483 | - added RewriteDestination configuration flag to enable rewriting the Destination header 484 | - time to serve the requests is logged in LogLevel 2 485 | 486 | Bug fixes: 487 | - fixed (again) the RewriteRedirect 2 mode 488 | 489 | ------------------------------------------------------------------------ 490 | r29 | roseg | 2006-09-11 18:35:22 +0200 (Mon, 11 Sep 2006) | 11 lines 491 | 492 | Release 2.1.1 493 | 494 | Enhancements: 495 | - SESS_IP now behaves like other session types (no longer sticky) 496 | - added RewriteLocation 2: rewrite location if it points to same address, but ignore port 497 | 498 | Bug fixes: 499 | - fixed problem in str_be (evident mostly in LogLevel 2) 500 | - added 'const' wherever necessary 501 | - check for errors in mutex handling 502 | 503 | ------------------------------------------------------------------------ 504 | r27 | roseg | 2006-08-05 11:35:52 +0200 (Sat, 05 Aug 2006) | 24 lines 505 | 506 | Release 2.1 507 | 508 | Enhancements: 509 | - support for pcre library (if available) for much better performance 510 | - support for hoard library (if available) for much better performance 511 | - rewrite Location and Content-location headers for all responses 512 | - improved detection of when is a rewrite necessary 513 | - renamed Change30x to RewriteLocation. Default: on 514 | 515 | Bug fixes: 516 | - fixed small problem in the upd_session() code 517 | - declared init_RSAgen() as void everywhere 518 | - moved to SESS_xxx tokens to avoid Solaris name conflict 519 | - added #ifdef's for LOG_FTP and LOG_AUTHPRIV 520 | - fixed problem in URL checking 521 | - fixed problem in session tracking-code and session updating 522 | - fixed LogLevel 3 to show that the v_host is unknown 523 | - fixed headers checking in match_service 524 | - fixed problem in ClientCert directive handling 525 | - fixed potential memory leak in AUTH decoding 526 | - allow OPTIONS WebDAV request to have content 527 | - replaced inet_ntoa with inet_ntop where available 528 | - removed all static buffers 529 | 530 | ------------------------------------------------------------------------ 531 | r25 | roseg | 2006-02-01 10:00:42 +0100 (Wed, 01 Feb 2006) | 14 lines 532 | 533 | Release 2.0 534 | 535 | Enhancements: 536 | - new configuration file syntax, offering significant improvements. 537 | - the ability to define listener-specific back-ends. In most cases 538 | this should eliminate the need for multiple Pound instances. 539 | - a new type of back-end: the redirector allows you to respond with 540 | a redirect without involving any back-end server. 541 | - most "secondary" properties (such as error messages, client 542 | time-out, etc.) are now private to listeners. 543 | - HAport has an optional address, different from the main back-end 544 | - added a -V flag for version 545 | - session keeping on a specific Header 546 | 547 | ------------------------------------------------------------------------ 548 | r21 | roseg | 2006-02-01 14:27:19 +0100 (Wed, 01 Feb 2006) | 15 lines 549 | 550 | Release 1.10 551 | 552 | Enhancements: 553 | added NoDaemon configuration directive (replaces compile-time switch) 554 | added LogFacility configuration directive (replaces compile-time switch) 555 | added user name logging 556 | 557 | Bug fixes: 558 | fixed problem with the poll() code 559 | fixed problem with empty list in gethostbyname() 560 | added call to setsid() if daemon 561 | conflicting headers are removed (Content-length - Transfer-encoding) 562 | 563 | Last release in the 1.x series. 564 | 565 | ------------------------------------------------------------------------ 566 | r19 | roseg | 2005-06-01 15:27:19 +0200 (Wed, 01 Jun 2005) | 18 lines 567 | 568 | Release 1.9 569 | 570 | Enhancements: 571 | - Added the VerifyList configuration flag (CA root certs + CRL) 572 | - CRL checking code 573 | - RewriteRedirect 2 - ignores port value for host matching 574 | - Added -c flag (check-only mode) 575 | - Added -v flag (verbose mode) 576 | - Added -p flag for pid file name 577 | 578 | Bug fixes: 579 | - fixed a potential buffer overflow problem (in checking the Host header) 580 | - added call to SSL_library_init 581 | - added a check for MSIE before forcing SSL shutdown 582 | - X-SSL-Cipher header is added only if HTTPSHeaders is non-zero 583 | - added code for shorter linger on badly closed connections (IE work-around) 584 | - fixed the locking for session checking (mutex_lock/unlock) 585 | 586 | ------------------------------------------------------------------------ 587 | r17 | roseg | 2004-11-04 14:27:19 +0100 (Thu, 04 Nov 2004) | 23 lines 588 | 589 | Release 1.8 590 | 591 | Changes: 592 | - added support for non-blocking connect(2) 593 | - added support for 414 - Request URI too long 594 | - added RedirectRewrite directive - to prevent redirect changes 595 | - added support for NoHTTPS11 value 2 (for MSIE clients only) 596 | - added support for HTTPSHeaders 3 (no verify) 597 | 598 | Problems fixed: 599 | - fixed bug if multiple listening ports/addresses 600 | - fixed memory leak in SSL 601 | - flush stdout (if used) after each log message 602 | - assumes only 304, 305 and 306 codes to have no content 603 | - fixed problem with delays in 302 without content 604 | - fixed problem with time-outs in HTTPS 605 | 606 | Enhancements: 607 | - improved threads detection code in autoconf 608 | - added supervisor process disable configuration flag 609 | - tweak for the Location rewriting code (only look at current GROUP) 610 | - improved print-out for client certificate information 611 | 612 | ------------------------------------------------------------------------ 613 | r15 | roseg | 2004-03-24 14:27:19 +0100 (Wed, 24 Mar 2004) | 12 lines 614 | 615 | Release 1.7 616 | 617 | Fixed bug in X-SSL-CIPHER description 618 | Changed README to stx format for consistency 619 | Addedd X-SSL-certificate with full client certificate 620 | Improved the response times on HTTP/0.9 (content without Content-length) 621 | Improved response granularity on above - using unbuffered BIO now 622 | Fixed problem with IE/SSL (SSL_set_shutdown) 623 | Avoid error messages on premature EOF from client 624 | Fixed HeadRemove code so all headers are checked without exception 625 | Improved autoconf detection 626 | 627 | ------------------------------------------------------------------------ 628 | r13 | roseg | 2003-11-30 14:27:19 +0100 (Sun, 30 Nov 2003) | 15 lines 629 | 630 | Release 1.6 631 | 632 | Callback for RSA ephemeral keys: 633 | - generated in a separate thread 634 | - used if required (IE 5.0?) 635 | New X-SSL-cipher header encryption level/method 636 | Added CheckURL parameter in config file 637 | - perform syntax check only if value 1 (default 0) 638 | Allow for empty query/param strings in URL syntax 639 | Additional SSL engine loading code 640 | Added parameter for CA certificates 641 | - CA list is sent to client 642 | Verify client certificates up to given depth 643 | Fixed vulnerability in syslog handling 644 | 645 | ------------------------------------------------------------------------ 646 | r11 | roseg | 2003-10-14 15:27:19 +0200 (Tue, 14 Oct 2003) | 19 lines 647 | 648 | Release 1.5 649 | 650 | Session by Basic Authentication: 651 | Session BASIC parameter added 652 | Syntax checking of request. 653 | User-defined request character set(s): 654 | Parameters CSsegment, CSparameter, CSqid, CSqval 655 | Request size limit: 656 | Parameter MaxRequest 657 | Single log function rather than #ifdefs. 658 | Added LogLevel 4 (same as 3 but without the virtual host info). 659 | Added HeadRemove directive (allows to delete a header from requests). 660 | Location rewriting on redirect: 661 | if the request contains a Header directive 662 | and the response is codes 301, 302, 303, 307 663 | and the Location in the response is to a known host 664 | then the Location header in the response will be rewritten to point 665 | to the Pound protocol/port itself 666 | 667 | ------------------------------------------------------------------------ 668 | r9 | roseg | 2003-04-24 15:27:19 +0200 (Thu, 24 Apr 2003) | 12 lines 669 | 670 | Release 1.4 671 | 672 | Added 'Server' configuration directive 673 | Fixed problem with HTTPSHeaders 0 "..." - the desired header is written even if HTTPSHeaders is 0 674 | Added the ability of loading a certificate chain. 675 | Added compatability with OpenSSL 0.9.7 676 | Added user-definable error pages. 677 | Added compile-time flags to run in foreground and to log to stderr. 678 | Opens separate pid files per-process. 679 | Improved autoconf. 680 | Some SSL speed optimisations. 681 | 682 | ------------------------------------------------------------------------ 683 | r7 | roseg | 2003-02-19 14:27:19 +0100 (Wed, 19 Feb 2003) | 10 lines 684 | 685 | Release 1.3 686 | 687 | Added support for OpenSSL Engine (crypto hardware) 688 | Added support for Subversion WebDAV 689 | Added support for mandatory client certificates 690 | Added X-SSL-serial header for SSL connections 691 | Fixed problem with BIO_pending in is_readable 692 | Fixed problem with multi-threading in OpenSSL 693 | Improved autoconf 694 | 695 | ------------------------------------------------------------------------ 696 | r5 | roseg | 2003-01-20 14:27:19 +0100 (Mon, 20 Jan 2003) | 5 lines 697 | 698 | Release 1.2 699 | 700 | Better handling of "100 Continue" responses 701 | Fixed problem with allowed character set for requests 702 | 703 | ------------------------------------------------------------------------ 704 | r3 | roseg | 2003-01-09 14:27:19 +0100 (Thu, 09 Jan 2003) | 9 lines 705 | 706 | Better auto-conf detection 707 | LogLevel 3 for Apache-like log (Combined Log Format) 708 | Don't ask client for certificate if no SSL headers required 709 | Added handling for 'Connection: closed' header 710 | Added monitor process to restart worker process if crashed 711 | Added possibility to listen on all interfaces 712 | Fixed HeadDeny code 713 | Fixed problem with threads on *BSD 714 | 715 | ------------------------------------------------------------------------ 716 | r1 | roseg | 2002-10-31 14:27:19 +0100 (Thu, 31 Oct 2002) | 1 line 717 | 718 | Initial import 719 | ------------------------------------------------------------------------ 720 | -------------------------------------------------------------------------------- /z2_2_5_1.py: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # 3 | # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. 4 | # 5 | # This software is subject to the provisions of the Zope Public License, 6 | # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. 7 | # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED 8 | # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 9 | # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS 10 | # FOR A PARTICULAR PURPOSE 11 | # 12 | ############################################################################## 13 | """Zope 2 ZServer start-up file 14 | 15 | Usage: %(program)s [options] [environment settings] 16 | 17 | Options: 18 | 19 | -h 20 | 21 | Output this text. 22 | 23 | -z path 24 | 25 | The location of the Zope installation. 26 | The default is the location of this script, %(here)s. 27 | 28 | -Z path 29 | 30 | Unix only! This option is ignored on windows. 31 | 32 | If this option is specified, a separate managemnt process will 33 | be created that restarts Zope after a shutdown (or crash). 34 | The path must point to a pid file that the process will record its 35 | process id in. The path may be relative, in which case it will be 36 | relative to the Zope location. 37 | 38 | To prevent use of a separate management process, provide an 39 | empty string: -Z '' 40 | 41 | -t n 42 | 43 | The number of threads to use, if ZODB3 is used. The default is 44 | %(NUMBER_OF_THREADS)s. 45 | 46 | -i n 47 | 48 | Set the interpreter check interval. This integer value 49 | determines how often the interpreter checks for periodic things 50 | such as thread switches and signal handlers. The Zope default 51 | is 120, but you may want to experiment with other values that 52 | may increase performance in your particular environment. 53 | 54 | -D 55 | 56 | Run in Zope debug mode. This causes the Zope process not to 57 | detach from the controlling terminal, and is equivalent to 58 | supplying the environment variable setting Z_DEBUG_MODE=1 59 | 60 | -a ipaddress 61 | 62 | The IP address to listen on. If this is an empty string 63 | (e.g. -a ''), then all addresses on the machine are used. The 64 | default is %(IP_ADDRESS)s. 65 | 66 | -d ipaddress 67 | 68 | IP address of your DNS server. If this is an empty string 69 | (e.g. -d ''), then IP addresses will not be logged. If you have 70 | DNS service on your local machine then you can set this to 71 | 127.0.0.1. The default is: %(DNS_IP)s. 72 | 73 | -u username or uid number 74 | 75 | The username to run ZServer as. You may want to run ZServer as 'nobody' 76 | or some other user with limited resouces. The only works under Unix, and 77 | if ZServer is started by root. The default is: %(UID)s 78 | 79 | -P [ipaddress:]number 80 | 81 | Set the web, ftp and monitor port numbers simultaneously 82 | as offsets from the number. The web port number will be number+80. 83 | The FTP port number will be number+21. The monitor port number will 84 | be number+99. 85 | 86 | The number can be preeceeded by an ip address follwed by a colon 87 | to specify an address to listen on. This allows different servers 88 | to listen on different addresses. 89 | 90 | Multiple -P options can be provided to run multiple sets of servers. 91 | 92 | -w port 93 | 94 | The Web server (HTTP) port. This defaults to %(HTTP_PORT)s. The 95 | standard port for HTTP services is 80. If this is a dash 96 | (e.g. -w -), then HTTP is disabled. 97 | 98 | The number can be preeceeded by an ip address follwed by a colon 99 | to specify an address to listen on. This allows different servers 100 | to listen on different addresses. 101 | 102 | Multiple -w options can be provided to run multiple servers. 103 | 104 | -y port 105 | 106 | The encrypted Web server (HTTPS) port. This defaults to %(HTTPS_PORT)s. 107 | The standard port for HTTP services is 443. If this is a dash 108 | (e.g. -y -), then HTTPS is disabled. 109 | 110 | The number can be preeceeded by an ip address follwed by a colon 111 | to specify an address to listen on. This allows different servers 112 | to listen on different addresses. 113 | 114 | Multiple -y options can be provided to run multiple servers. 115 | 116 | -W port 117 | 118 | The "WebDAV source" port. If this is a dash (e.g. -W -), then 119 | "WebDAV source" is disabled. The default is disabled. Note that 120 | this feature is a workaround for the lack of "source-link" support 121 | in standard WebDAV clients. 122 | 123 | The port can be preeceeded by an ip address follwed by a colon 124 | to specify an address to listen on. This allows different servers 125 | to listen on different addresses. 126 | 127 | Multiple -W options can be provided to run multiple servers. 128 | 129 | -f port 130 | 131 | The FTP port. If this is a dash (e.g. -f -), then FTP 132 | is disabled. The standard port for FTP services is 21. The 133 | default is %(FTP_PORT)s. 134 | 135 | The port can be preeceeded by an ip address follwed by a colon 136 | to specify an address to listen on. This allows different servers 137 | to listen on different addresses. 138 | 139 | Multiple -f options can be provided to run multiple servers. 140 | 141 | -p path 142 | 143 | Path to the PCGI resource file. The default value is 144 | %(PCGI_FILE)s, relative to the Zope location. If this is a dash 145 | (-p -) or the file does not exist, then PCGI is disabled. 146 | 147 | -F path_or_port 148 | 149 | Either a port number (for inet sockets) or a path name (for unix 150 | domain sockets) for the FastCGI Server. If the flag and value are 151 | not specified then the FastCGI Server is disabled. 152 | 153 | -m port 154 | 155 | The secure monitor server port. If this is a dash 156 | (-m -), then the monitor server is disabled. The monitor server 157 | allows interactive Python style access to a running ZServer. To 158 | access the server see medusa/monitor_client.py or 159 | medusa/monitor_client_win32.py. The monitor server password is the 160 | same as the Zope emergency user password set in the 'access' 161 | file. The default is to not start up a monitor server. 162 | 163 | The port can be preeceeded by an ip address follwed by a colon 164 | to specify an address to listen on. This allows different servers 165 | to listen on different addresses. 166 | 167 | Multiple -m options can be provided to run multiple servers. 168 | 169 | -l path 170 | 171 | Path to the ZServer log file. If this is a relative path then the 172 | log file will be written to the 'var' directory. The default is 173 | %(LOG_FILE)s. 174 | 175 | -r 176 | 177 | Run ZServer is read-only mode. ZServer won't write anything to disk. 178 | No log files, no pid files, nothing. This means that you can't do a 179 | lot of stuff like use PCGI, and zdaemon. ZServer will log hits to 180 | STDOUT and zLOG will log to STDERR. 181 | 182 | -L 183 | 184 | Enable locale (internationalization) support. The value passed for 185 | this option should be the name of the locale to be used (see your 186 | operating system documentation for locale information specific to 187 | your system). If an empty string is passed for this option (-L ''), 188 | Zope will set the locale to the user's default setting (typically 189 | specified in the $LANG environment variable). If your Python 190 | installation does not support the locale module, the requested 191 | locale is not supported by your system or an empty string was 192 | passed but no default locale can be found, an error will be raised 193 | and Zope will not start. 194 | 195 | -X 196 | 197 | Disable servers. This might be used to effectively disable all 198 | default server settings or previous server settings in the option 199 | list before providing new settings. For example to provide just a 200 | web server: 201 | 202 | %(program)s -X -w80 203 | 204 | -M file 205 | 206 | Save detailed logging information to the given file. 207 | This log includes separate entries for: 208 | 209 | - The start of a request, 210 | - The start of processing the request in an application thread, 211 | - The start of response output, and 212 | - The end of the request. 213 | 214 | Environment settings are of the form: NAME=VALUE. 215 | 216 | Note: you *must* use Python 2.1 or later! 217 | """ 218 | 219 | 220 | # This is required path hackery for the win32 binary distribution 221 | # that ensures that the bundled python libraries are used. In a 222 | # win32 binary distribution, the installer will have replaced the 223 | # marker string with the actual software home. If that has not 224 | # happened, then the path munging code is skipped. 225 | swhome=r'INSERT_SOFTWARE_HOME' 226 | if swhome != 'INSERT_SOFTWARE_HOME': 227 | import sys 228 | sys.path.insert(0, '%s/lib/python' % swhome) 229 | sys.path.insert(1, '%s/bin/lib' % swhome) 230 | sys.path.insert(2, '%s/bin/lib/plat-win' % swhome) 231 | sys.path.insert(3, '%s/bin/lib/win32' % swhome) 232 | sys.path.insert(4, '%s/bin/lib/win32/lib' % swhome) 233 | sys.path.insert(5, '%s' % swhome) 234 | 235 | 236 | import os, sys, getopt, string, codecs 237 | # workaround to allow unicode encoding conversions in DTML 238 | dummy = codecs.lookup('iso-8859-1') 239 | 240 | sys.setcheckinterval(120) 241 | 242 | 243 | program=sys.argv[0] 244 | here=os.path.join(os.getcwd(), os.path.split(program)[0]) 245 | Zpid='' 246 | 247 | ######################################################################## 248 | # Configuration section 249 | 250 | ## General configuration options 251 | ## 252 | 253 | # If you want run as a daemon, then uncomment the line below: 254 | if sys.platform=='win32': Zpid='' 255 | else: Zpid='zProcessManager.pid' 256 | 257 | # This is the IP address of the network interface you want your servers to 258 | # be visible from. This can be changed to '' to listen on all interfaces. 259 | IP_ADDRESS='' 260 | 261 | # IP address of your DNS server. Set to '' if you do not want to resolve 262 | # IP addresses. If you have DNS service on your local machine then you can 263 | # set this to '127.0.0.1' 264 | DNS_IP='' 265 | 266 | # User id to run ZServer as. Note that this only works under Unix, and if 267 | # ZServer is started by root. 268 | UID='nobody' 269 | 270 | # Log file location. If this is a relative path, then it is joined the 271 | # the 'var' directory. 272 | LOG_FILE='Z2.log' 273 | 274 | ## HTTP configuration 275 | ## 276 | 277 | # Port for HTTP Server. The standard port for HTTP services is 80. 278 | HTTP_PORT=8080 279 | 280 | # HTTP enivornment settings. 281 | HTTP_ENV={} 282 | 283 | # Port for HTTPS Server. The standard port for HTTPS services is 443. 284 | HTTPS_PORT=8443 285 | 286 | # HTTPS enivornment settings. 287 | HTTPS_ENV={} 288 | 289 | # Port for the special "WebDAV source view" HTTP handler. There is no 290 | # standard port for this handler, which is disabled by default. 291 | WEBDAV_SOURCE_PORT=[] 292 | 293 | ## FTP configuration 294 | 295 | # Port for the FTP Server. The standard port for FTP services is 21. 296 | FTP_PORT=8021 297 | 298 | ## PCGI configuration 299 | 300 | # You can configure the PCGI server manually, or have it read its 301 | # configuration information from a PCGI info file. 302 | PCGI_FILE='Zope.cgi' 303 | 304 | ## Monitor configuration 305 | MONITOR_PORT=0 306 | 307 | # Module to be published, which must be Main or Zope 308 | MODULE='Zope' 309 | 310 | # The size of the thread pool, if ZODB3 is used. 311 | NUMBER_OF_THREADS=4 312 | 313 | 314 | # Localization support 315 | LOCALE_ID=None 316 | 317 | 318 | 319 | # Socket path or port for the FastCGI Server 320 | FCGI_PORT=None 321 | 322 | # Detailed log file 323 | DETAILED_LOG_FILE='' 324 | 325 | # 326 | ######################################################################## 327 | 328 | ######################################################################## 329 | # Handle command-line arguments: 330 | 331 | def server_info(old, v, offset=0): 332 | # interpret v as a port or address/port and get new value 333 | if v == '-': v='' 334 | l=string.find(v, ':') 335 | if l >= 0: 336 | a=v[:l] 337 | v=v[l+1:] 338 | else: 339 | a=IP_ADDRESS 340 | 341 | if not v: return v 342 | 343 | try: 344 | v=string.atoi(v) 345 | if v < 0: raise 'Invalid port', v 346 | v=v+offset 347 | except: raise 'Invalid port', v 348 | 349 | if type(old) is type(0): old=[(a,v)] 350 | else: old.append((a,v)) 351 | 352 | return old 353 | 354 | 355 | try: 356 | if string.split(sys.version)[0] < '2.1': 357 | raise 'Invalid python version', string.split(sys.version)[0] 358 | 359 | opts, args = getopt.getopt(sys.argv[1:], 360 | 'hz:Z:t:i:a:d:u:w:y:W:f:p:m:Sl:2DP:rF:L:XM:') 361 | 362 | DEBUG=0 363 | READ_ONLY=0 364 | 365 | # Get environment variables 366 | for a in args: 367 | if string.find(a,'='): 368 | a=string.split(a,'=') 369 | o=a[0] 370 | v=string.join(a[1:],'=') 371 | if o: 372 | os.environ[o]=v 373 | HTTP_ENV[o]=v 374 | HTTPS_ENV[o]=v 375 | else: 376 | raise 'Invalid argument', a 377 | 378 | for o, v in opts: 379 | if o=='-z': here=v 380 | elif o=='-Z': 381 | if v=='-': v='' 382 | Zpid=v 383 | elif o=='-r': READ_ONLY=1 384 | elif o=='-t': 385 | try: v=string.atoi(v) 386 | except: raise 'Invalid number of threads', v 387 | NUMBER_OF_THREADS=v 388 | 389 | elif o=='-i': 390 | try: v=string.atoi(v) 391 | except: raise 'Invalid value for -i option', v 392 | sys.setcheckinterval(v) 393 | 394 | elif o=='-a': IP_ADDRESS=v 395 | elif o=='-d': 396 | if v=='-': v='' 397 | DNS_IP=v 398 | elif o=='-u': UID=v 399 | elif o=='-D': 400 | os.environ['Z_DEBUG_MODE']='1' 401 | DEBUG=1 402 | elif o=='-S': sys.ZMANAGED=1 403 | elif o=='-X': 404 | MONITOR_PORT=HTTP_PORT=HTTPS_PORT=FTP_PORT=FCGI_PORT=0 405 | PCGI_FILE='' 406 | elif o=='-m': 407 | MONITOR_PORT=server_info(MONITOR_PORT, v) 408 | elif o=='-w': 409 | HTTP_PORT=server_info(HTTP_PORT, v) 410 | elif o=='-y': 411 | HTTPS_PORT=server_info(HTTPS_PORT, v) 412 | elif o=='-W': 413 | WEBDAV_SOURCE_PORT=server_info(WEBDAV_SOURCE_PORT, v) 414 | elif o=='-f': 415 | FTP_PORT=server_info(FTP_PORT, v) 416 | elif o=='-P': 417 | HTTP_PORT=server_info(HTTP_PORT, v, 80) 418 | HTTPS_PORT=server_info(HTTPS_PORT, v, 443) 419 | FTP_PORT=server_info(FTP_PORT, v, 21) 420 | 421 | elif o=='-p': 422 | if v=='-': v='' 423 | PCGI_FILE=v 424 | elif o=='-h': 425 | print __doc__ % vars() 426 | sys.exit(0) 427 | elif o=='-2': MODULE='Main' 428 | elif o=='-l': LOG_FILE=v 429 | elif o=='-L': 430 | if v: LOCALE_ID=v 431 | else: LOCALE_ID='' 432 | elif o=='-F': 433 | if v=='-': v='' 434 | FCGI_PORT=v 435 | elif o=='-M': DETAILED_LOG_FILE=v 436 | 437 | except SystemExit: sys.exit(0) 438 | except: 439 | print __doc__ % vars() 440 | print 441 | print 'Error:' 442 | print "%s: %s" % (sys.exc_type, sys.exc_value) 443 | sys.exit(1) 444 | 445 | if sys.platform=='win32': Zpid='' 446 | 447 | # 448 | ######################################################################## 449 | 450 | ######################################################################## 451 | # OK, let's get going! 452 | 453 | # Jigger path: 454 | sys.path=[os.path.join(here,'lib','python'),here 455 | ]+filter(None, sys.path) 456 | 457 | 458 | 459 | # Try to set the locale if specified on the command 460 | # line. If the locale module is not available or the 461 | # requested locale is not supported by the local 462 | # machine, raise an error so that the user is made 463 | # aware of the problem. 464 | 465 | def set_locale(val): 466 | try: 467 | import locale 468 | except: 469 | raise SystemExit, ( 470 | 'The locale module could not be imported.\n' 471 | 'To use localization options, you must ensure\n' 472 | 'that the locale module is compiled into your\n' 473 | 'Python installation.' 474 | ) 475 | try: 476 | locale.setlocale(locale.LC_ALL, val) 477 | except: 478 | raise SystemExit, ( 479 | 'The specified locale is not supported by your system.\n' 480 | 'See your operating system documentation for more\n' 481 | 'information on locale support.' 482 | ) 483 | if LOCALE_ID is not None: 484 | set_locale(LOCALE_ID) 485 | 486 | 487 | # from this point forward we can use the zope logger 488 | 489 | # Import ZServer before we open the database or get at interesting 490 | # application code so that ZServer's asyncore gets to be the 491 | # official one. Also gets SOFTWARE_HOME, INSTANCE_HOME, and CLIENT_HOME 492 | import ZServer 493 | 494 | if Zpid and not READ_ONLY: 495 | import zdaemon, App.FindHomes, posix 496 | sys.ZMANAGED=1 497 | 498 | zdaemon.run(sys.argv, os.path.join(CLIENT_HOME, Zpid)) 499 | 500 | try: 501 | # Import logging support 502 | import zLOG 503 | import ZLogger 504 | 505 | if READ_ONLY: 506 | if hasattr(zLOG, '_set_stupid_dest'): 507 | zLOG._set_stupid_dest(sys.stderr) 508 | else: 509 | zLOG._stupid_dest = sys.stderr 510 | else: 511 | zLOG.log_write = ZLogger.ZLogger.log_write 512 | 513 | if DETAILED_LOG_FILE: 514 | from ZServer import DebugLogger 515 | logfile=os.path.join(CLIENT_HOME, DETAILED_LOG_FILE) 516 | DebugLogger.log=DebugLogger.DebugLogger(logfile).log 517 | 518 | # Import Zope (or Main) 519 | exec "import "+MODULE in {} 520 | 521 | # Location of the ZServer log file. This file logs all ZServer activity. 522 | # You may wish to create different logs for different servers. See 523 | # medusa/logger.py for more information. 524 | if not os.path.isabs(LOG_FILE): 525 | LOG_PATH=os.path.join(CLIENT_HOME, LOG_FILE) 526 | else: 527 | LOG_PATH=LOG_FILE 528 | 529 | # Location of the ZServer pid file. When ZServer starts up it will write 530 | # its PID to this file. 531 | PID_FILE=os.path.join(CLIENT_HOME, 'Z2.pid') 532 | 533 | 534 | # import ZServer stuff 535 | 536 | # First, we need to increase the number of threads 537 | if MODULE=='Zope': 538 | from ZServer import setNumberOfThreads 539 | setNumberOfThreads(NUMBER_OF_THREADS) 540 | 541 | from ZServer import resolver, logger, asyncore 542 | 543 | from ZServer import zhttp_server, zhttp_handler 544 | from ZServer.WebDAVSrcHandler import WebDAVSrcHandler 545 | from ZServer import PCGIServer,FTPServer,FCGIServer 546 | 547 | from ZServer import secure_monitor_server 548 | 549 | ## ZServer startup 550 | ## 551 | 552 | # Resolver and Logger, used by other servers 553 | if DNS_IP: 554 | rs = resolver.caching_resolver(DNS_IP) 555 | else: 556 | rs=None 557 | 558 | if READ_ONLY: 559 | lg = logger.file_logger('-') # log to stdout 560 | elif os.environ.has_key('ZSYSLOG'): 561 | lg = logger.syslog_logger(os.environ['ZSYSLOG']) 562 | if os.environ.has_key("ZSYSLOG_FACILITY"): 563 | lg = logger.syslog_logger(os.environ['ZSYSLOG'],facility=os.environ['ZSYSLOG_FACILITY']) 564 | else: 565 | lg = logger.syslog_logger(os.environ['ZSYSLOG']) 566 | elif os.environ.has_key('ZSYSLOG_SERVER'): 567 | (addr, port) = string.split(os.environ['ZSYSLOG_SERVER'], ':') 568 | lg = logger.syslog_logger((addr, int(port))) 569 | else: 570 | lg = logger.file_logger(LOG_PATH) 571 | 572 | # HTTP Server 573 | if HTTP_PORT: 574 | if type(HTTP_PORT) is type(0): HTTP_PORT=((IP_ADDRESS, HTTP_PORT),) 575 | for address, port in HTTP_PORT: 576 | hs = zhttp_server( 577 | ip=address, 578 | port=port, 579 | resolver=rs, 580 | logger_object=lg) 581 | 582 | # Handler for a published module. zhttp_handler takes 3 arguments: 583 | # The name of the module to publish, and optionally the URI base 584 | # which is basically the SCRIPT_NAME, and optionally a dictionary 585 | # with CGI environment variables which override default 586 | # settings. The URI base setting is useful when you want to 587 | # publish more than one module with the same HTTP server. The CGI 588 | # environment setting is useful when you want to proxy requests 589 | # from another web server to ZServer, and would like the CGI 590 | # environment to reflect the CGI environment of the other web 591 | # server. 592 | zh = zhttp_handler(MODULE, '', HTTP_ENV) 593 | hs.install_handler(zh) 594 | 595 | # HTTPS Server 596 | if HTTPS_PORT: 597 | if type(HTTPS_PORT) is type(0): HTTPS_PORT=((IP_ADDRESS, HTTPS_PORT),) 598 | for address, port in HTTPS_PORT: 599 | hs = zhttp_server( 600 | ip=address, 601 | port=port, 602 | resolver=rs, 603 | logger_object=lg) 604 | 605 | # Handler for a published module. zhttp_handler takes 3 arguments: 606 | # The name of the module to publish, and optionally the URI base 607 | # which is basically the SCRIPT_NAME, and optionally a dictionary 608 | # with CGI environment variables which override default 609 | # settings. The URI base setting is useful when you want to 610 | # publish more than one module with the same HTTP server. The CGI 611 | # environment setting is useful when you want to proxy requests 612 | # from another web server to ZServer, and would like the CGI 613 | # environment to reflect the CGI environment of the other web 614 | # server. 615 | 616 | try: 617 | del HTTPS_ENV['HTTP'] 618 | except KeyError: 619 | pass 620 | HTTPS_ENV['HTTPS']='ON' 621 | 622 | zh = zhttp_handler(MODULE, '', HTTPS_ENV) 623 | hs.install_handler(zh) 624 | 625 | # WebDAV source Server (runs HTTP, but munges request to return 626 | # 'manage_FTPget'). 627 | if WEBDAV_SOURCE_PORT: 628 | if type(WEBDAV_SOURCE_PORT) is type(0): 629 | WEBDAV_SOURCE_PORT=((IP_ADDRESS, WEBDAV_SOURCE_PORT),) 630 | for address, port in WEBDAV_SOURCE_PORT: 631 | hs = zhttp_server( 632 | ip=address, 633 | port=port, 634 | resolver=rs, 635 | logger_object=lg) 636 | 637 | # Handler for a published module. zhttp_handler takes 3 arguments: 638 | # The name of the module to publish, and optionally the URI base 639 | # which is basically the SCRIPT_NAME, and optionally a dictionary 640 | # with CGI environment variables which override default 641 | # settings. The URI base setting is useful when you want to 642 | # publish more than one module with the same HTTP server. The CGI 643 | # environment setting is useful when you want to proxy requests 644 | # from another web server to ZServer, and would like the CGI 645 | # environment to reflect the CGI environment of the other web 646 | # server. 647 | zh = WebDAVSrcHandler(MODULE, '', HTTP_ENV) 648 | hs.install_handler(zh) 649 | 650 | # FTP Server 651 | if FTP_PORT: 652 | if type(FTP_PORT) is type(0): FTP_PORT=((IP_ADDRESS, FTP_PORT),) 653 | for address, port in FTP_PORT: 654 | FTPServer( 655 | module=MODULE, 656 | ip=address, 657 | port=port, 658 | resolver=rs, 659 | logger_object=lg) 660 | 661 | # PCGI Server 662 | if PCGI_FILE and not READ_ONLY: 663 | PCGI_FILE=os.path.join(here, PCGI_FILE) 664 | if os.path.exists(PCGI_FILE): 665 | zpcgi = PCGIServer( 666 | module=MODULE, 667 | ip=IP_ADDRESS, 668 | pcgi_file=PCGI_FILE, 669 | resolver=rs, 670 | logger_object=lg) 671 | 672 | 673 | # FastCGI Server 674 | if FCGI_PORT and not READ_ONLY: 675 | fcgiPort = None 676 | fcgiPath = None 677 | try: 678 | fcgiPort = string.atoi(FCGI_PORT) 679 | except ValueError: 680 | fcgiPath = FCGI_PORT 681 | zfcgi = FCGIServer(module=MODULE, 682 | ip=IP_ADDRESS, 683 | port=fcgiPort, 684 | socket_file=fcgiPath, 685 | resolver=rs, 686 | logger_object=lg) 687 | 688 | 689 | # Monitor Server 690 | if MONITOR_PORT: 691 | from AccessControl.User import emergency_user 692 | if not hasattr(emergency_user, '__null_user__'): 693 | pw = emergency_user._getPassword() 694 | else: 695 | pw = None 696 | zLOG.LOG("z2", zLOG.WARNING, 'Monitor server not started' 697 | ' because no emergency user exists.') 698 | if pw: 699 | if type(MONITOR_PORT) is type(0): 700 | MONITOR_PORT=((IP_ADDRESS, MONITOR_PORT),) 701 | for address, port in MONITOR_PORT: 702 | monitor=secure_monitor_server( 703 | password=pw, 704 | hostname=address, 705 | port=port) 706 | 707 | # Try to set uid to "-u" -provided uid. 708 | # Try to set gid to "-u" user's primary group. 709 | # This will only work if this script is run by root. 710 | try: 711 | import pwd 712 | try: 713 | try: UID = string.atoi(UID) 714 | except: pass 715 | gid = None 716 | if type(UID) == type(""): 717 | uid = pwd.getpwnam(UID)[2] 718 | gid = pwd.getpwnam(UID)[3] 719 | elif type(UID) == type(1): 720 | uid = pwd.getpwuid(UID)[2] 721 | gid = pwd.getpwuid(UID)[3] 722 | else: 723 | raise KeyError 724 | try: 725 | if gid is not None: 726 | try: 727 | os.setgid(gid) 728 | except OSError: 729 | pass 730 | os.setuid(uid) 731 | except OSError: 732 | pass 733 | except KeyError: 734 | zLOG.LOG("z2", zLOG.ERROR, ("can't find UID %s" % UID)) 735 | except: 736 | pass 737 | 738 | 739 | 740 | # if it hasn't failed at this point, create a .pid file. 741 | if not READ_ONLY: 742 | pf = open(PID_FILE, 'w') 743 | pid=str(os.getpid()) 744 | try: pid=str(os.getppid())+' '+pid 745 | except: pass 746 | pf.write(pid) 747 | pf.close() 748 | 749 | except: 750 | # Log startup exception and tell zdaemon not to restart us. 751 | try: 752 | zLOG.LOG("z2", zLOG.PANIC, "Startup exception", 753 | error=sys.exc_info()) 754 | except: pass 755 | sys.exit(0) 756 | 757 | # Start Medusa, Ye Hass! 758 | sys.ZServerExitCode=0 759 | asyncore.loop() 760 | sys.exit(sys.ZServerExitCode) 761 | -------------------------------------------------------------------------------- /GPL.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /pound.8: -------------------------------------------------------------------------------- 1 | .TH POUND "8" "Jan 2010" "pound" "System Manager's Manual" 2 | .SH NAME 3 | pound \- HTTP/HTTPS reverse-proxy and load-balancer 4 | .SH SYNOPSIS 5 | .TP 6 | .B pound 7 | [\fI-v\fR] 8 | [\fI-c\fR] 9 | [\fI-V\fR] 10 | [\fI-f config_file\fR] 11 | [\fI-p pid_file\fR] 12 | .SH DESCRIPTION 13 | .PP 14 | .B Pound 15 | is a reverse-proxy load balancing server. It accepts requests from HTTP/HTTPS 16 | clients and distributes them to one or more Web servers. The HTTPS requests are 17 | decrypted and passed to the back-ends as plain HTTP. 18 | .PP 19 | If more than one back-end server is defined, 20 | .B Pound 21 | chooses one of them randomly, based on defined priorities. By default, 22 | .B Pound 23 | keeps track of associations between clients and back-end servers (sessions). 24 | .SH GENERAL PRINCIPLES 25 | .P 26 | In general 27 | .B Pound 28 | needs three types of objects defined in order to function: 29 | .IR listeners , 30 | .I services 31 | and 32 | .IR back-ends . 33 | .TP 34 | \fBListeners\fR 35 | A 36 | .I listener 37 | is a definition of how 38 | .B Pound 39 | receives requests from the clients (browsers). Two types of 40 | .I listeners 41 | may be defined: regular HTTP 42 | .I listeners 43 | and HTTPS (HTTP over SSL/TLS) 44 | .IR listeners . 45 | At the very least a 46 | .I listener 47 | must define the address and port to listen on, with additional 48 | requirements for HTTPS 49 | .IR listeners . 50 | .TP 51 | \fBServices\fR 52 | A 53 | .I service 54 | is the definition of how the requests are answered. The 55 | .I services 56 | may be defined within a 57 | .I listener 58 | or at the top level (global). When a request is received 59 | .B Pound 60 | attempts to match them to each 61 | .I service 62 | in turn, starting with the 63 | .I services 64 | defined in the 65 | .I listener 66 | itself and, if needed, continuing with the 67 | .I services 68 | defined at the global level. The 69 | .I services 70 | may define their own conditions as to which requests they can answer: 71 | typically this involves certain URLs (images only, or a certain path) 72 | or specific headers (such as the Host header). A 73 | .I service 74 | may also define a 75 | .I session 76 | mechanism: if defined future requests from a given client will always 77 | be answered by the same 78 | .IR back-end . 79 | .TP 80 | \fBBack-ends\fR 81 | The 82 | .I back-ends 83 | are the actual servers for the content requested. By itself, 84 | .B Pound 85 | supplies no responses - all contents must be received from a "real" 86 | web server. The 87 | .I back-end 88 | defines how the server should be contacted. 89 | .IP 90 | Three types of 91 | .I back-ends 92 | may be defined: a "regular" 93 | .I back-end 94 | which receives requests and returns responses, a "redirect" 95 | .I back-end 96 | in which case 97 | .B Pound 98 | will respond with a redirect response, without accessing any 99 | .I back-end 100 | at all, or an "emergency" 101 | .I back-end 102 | which will be used only if all other backends are "dead". 103 | .IP 104 | Multiple 105 | .I back-ends 106 | may be defined within a 107 | .IR service , 108 | in which case 109 | .B Pound 110 | will load-balance between the available 111 | .IR back-ends . 112 | .IP 113 | If a 114 | .I back-end 115 | fails to respond it will be considered "dead", in which case 116 | .B Pound 117 | will stop sending requests to it. Dead 118 | .I back-ends 119 | are periodically checked for availability, and once they respond again they 120 | are "resurected" and requests are sent again their way. If no 121 | .I back-ends 122 | are available (none were defined, or all are "dead") then 123 | .B Pound 124 | will reply with "503 Service Unavailable", without checking additional 125 | .IR services . 126 | .IP 127 | The connection between 128 | .B Pound 129 | and the 130 | .I back-ends 131 | is always via HTTP, regardless of the actual protocol used between 132 | .B Pound 133 | and the client. 134 | .SH OPTIONS 135 | Options available (see also below for configuration file options): 136 | .TP 137 | \fB\-v\fR 138 | Verbose mode: error messages will be sent to stdout even if 139 | .B Pound 140 | was configured to log to syslog. This applies only to startup messages, before 141 | .B Pound 142 | puts itself in the background. Normal operational messages will still go to syslog. 143 | .TP 144 | \fB\-V\fR 145 | Print version: 146 | .B Pound 147 | will exit immediately after printing the current version and configuration flags. 148 | .TP 149 | \fB\-c\fR 150 | Check only: 151 | .B Pound 152 | will exit immediately after parsing the configuration file. This may be used for 153 | running a quick syntax check before actually activating a server. 154 | .TP 155 | \fB\-f\fR config_file 156 | Location of the configuration file (see below for a full description of the format). 157 | Default: 158 | .I /usr/local/etc/pound.cfg 159 | .TP 160 | \fB\-p\fR pid_file 161 | Location of the pid file. 162 | .B Pound 163 | will write its own pid into this file. Normally this is used for shell 164 | scripts that control starting and stopping of the daemon. 165 | Default: 166 | .I /var/run/pound.pid 167 | .PP 168 | In general, any number of back-end servers may be specified. Use the priority to 169 | affect the load distribution among unequal-performance servers. 170 | .PP 171 | One (or more) copies of 172 | .B Pound 173 | should be started at boot time. Use "big iron" if you expect heavy loads: while 174 | .B Pound 175 | is as light-weight as I know how to make it, with a lot of simultaneous requests it 176 | will use quite a bit of CPU and memory. Multiple CPUs are your friend. 177 | .SH "CONFIGURATION FILE" 178 | Each line in the file is considered a complete configuration directive. The directives 179 | are case-insensitive. Empty lines or lines starting in '#' are ignored. There are three 180 | types of directives: 181 | .B global 182 | directives (they affect the settings for the entire program instance), 183 | .B listener 184 | directives (they define which requests 185 | .B Pound 186 | will listen for), and 187 | .B service 188 | directives (they affect only a specific group of requests). 189 | .SH "GLOBAL DIRECTIVES" 190 | Global directives may appear anywhere within the configuration file, though it is 191 | customary for them to be at the start. They may appear in any order. 192 | .TP 193 | \fBUser\fR "user_name" 194 | Specify the user 195 | .B Pound 196 | will run as (must be defined in \fI/etc/passwd\fR). 197 | .TP 198 | \fBGroup\fR "group_name" 199 | Specify the group 200 | .B Pound 201 | will run as (must be defined in \fI/etc/group\fR). 202 | .TP 203 | \fBRootJail\fR "directory_path_and_name" 204 | Specify the directory that 205 | .B Pound 206 | will chroot to at runtime. Please note that OpenSSL requires access to /dev/urandom, 207 | so make sure you create a device by that name, accessible from the root jail 208 | directory. 209 | .B Pound 210 | may also require access to 211 | .I /dev/syslog 212 | or similar. 213 | .TP 214 | \fBDaemon\fR 0|1 215 | Have 216 | .B Pound 217 | run in the foreground (if 0) or as a daemon (if 1). By default 218 | .B Pound 219 | runs as a daemon (detaches itself from the controlling terminal and 220 | puts itself in the background). By specifying this option you can force 221 | .B Pound 222 | to work like a regular process. Useful for debugging or if you want to 223 | use something like \fIdaemontools\fR. 224 | .TP 225 | \fBLogFacility\fR value 226 | Specify the log facility to use. 227 | .I value 228 | (default: daemon) must be one of the symbolic facility names defined in 229 | \fIsyslog.h\fR. This facility shall be used for logging. Using a - for 230 | the facility name causes 231 | .B Pound 232 | to log to stdout/stderr. 233 | .TP 234 | \fBLogLevel\fR value 235 | Specify the logging level: 0 for no logging, 1 (default) for regular 236 | logging, 2 for extended logging (show chosen backend server as well), 237 | 3 for Apache-like format (Combined Log Format with Virtual Host), 4 238 | (same as 3 but without the virtual host information) and 5 (same as 4 239 | but with information about the 240 | .I Service 241 | and 242 | .I BackEnd 243 | used). 244 | This value can be overridden for specific listeners. 245 | .TP 246 | \fBIgnoreCase\fR 0|1 247 | Ignore case when matching URLs (default: 0). This value can be 248 | overridden for specific services. 249 | .TP 250 | \fBDynScale\fR 0|1 251 | Enable or disable the dynamic rescaling code (default: 0). If enabled 252 | .B Pound 253 | will periodically try to modify the back-end priorities in order to 254 | equalise the response times from the various back-ends. 255 | This value can be overridden for specific services. 256 | .TP 257 | \fBAlive\fR value 258 | Specify how often 259 | .B Pound 260 | will check for resurected back-end hosts (default: 30 seconds). In 261 | general, it is a good idea to set this as low as possible - it 262 | will find resurected hosts faster. However, if you set it too 263 | low it will consume resources - so beware. 264 | .TP 265 | \fBClient\fR value 266 | Specify for how long 267 | .B Pound 268 | will wait for a client request (default: 10 seconds). After this 269 | long has passed without the client sending any data 270 | .B Pound 271 | will close the connection. Set it higher if your clients 272 | time-out on a slow network or over-loaded server, lower if you 273 | start getting DOS attacks or run into problems with IE clients. 274 | This value can be overridden for specific listeners. 275 | .TP 276 | \fBTimeOut\fR value 277 | How long should 278 | .B Pound 279 | wait for a response from the back-end (in seconds). Default: 15 seconds. 280 | This value can be overridden for specific back-ends. 281 | .TP 282 | \fBConnTO\fR value 283 | How long should 284 | .B Pound 285 | wait for a connection to the back-end (in seconds). Default: the 286 | .B TimeOut 287 | value. This value can be overridden for specific back-ends. 288 | .TP 289 | \fBGrace\fR value 290 | How long should 291 | .B Pound 292 | continue to answer existing connections after a receiving and INT or HUP 293 | signal (default: 30 seconds). The configured listeners are closed 294 | immediately. You can bypass this behaviour by stopping 295 | .B Pound 296 | with a TERM or QUIT signal, in which case the program exits without any 297 | delay. 298 | .TP 299 | \fBSSLEngine\fR "name" 300 | Use an OpenSSL hardware acceleration card called \fIname\fR. Available 301 | only if OpenSSL-engine is installed on your system. 302 | .TP 303 | \fBControl\fR "/path/to/socket" 304 | Set the control socket path. If not defined 305 | .B Pound 306 | does not listen for any commands. The commands may be issued by using 307 | the 308 | .I poundctl(8) 309 | program. 310 | .SH "HTTP Listener" 311 | An HTTP listener defines an address and port that 312 | .B Pound 313 | will listen on for HTTP requests. All configuration directives enclosed 314 | between 315 | .I ListenHTTP 316 | and 317 | .I End 318 | are specific to a single HTTP listener. At the very least you must specify 319 | and address and a port for each listener. The following directives are 320 | available: 321 | .TP 322 | \fBAddress\fR address 323 | The address that 324 | .B Pound 325 | will listen on. This can be a numeric IP address, or a symbolic host name 326 | that must be resolvable at run-time. This is a 327 | .B mandatory 328 | parameter. The address 0.0.0.0 may be used as an alias for 'all available 329 | addresses on this machine', but this practice is strongly discouraged, as 330 | it will interfere with the rewriting mechanisms (see below). 331 | .TP 332 | \fBPort\fR port 333 | The port number that 334 | .B Pound 335 | will listen on. This is a 336 | .B mandatory 337 | parameter. 338 | .TP 339 | \fBxHTTP\fR value 340 | Defines which HTTP verbs are accepted. The possible values are: 341 | .IP 342 | .I 0 343 | (default) accept only standard HTTP requests (GET, POST, HEAD). 344 | .IP 345 | .I 1 346 | additionally allow extended HTTP requests (PUT, DELETE). 347 | .IP 348 | .I 2 349 | additionally allow standard WebDAV verbs (LOCK, UNLOCK, PROPFIND, 350 | PROPPATCH, SEARCH, MKCOL, MOVE, COPY, OPTIONS, TRACE, MKACTIVITY, 351 | CHECKOUT, MERGE, REPORT). 352 | .IP 353 | .I 3 354 | additionally allow MS extensions WebDAV verbs (SUBSCRIBE, UNSUBSCRIBE, 355 | NOTIFY, BPROPFIND, BPROPPATCH, POLL, BMOVE, BCOPY, BDELETE, CONNECT). 356 | .IP 357 | .I 4 358 | additionally allow MS RPC extensions verbs (RPC_IN_DATA, RPC_OUT_DATA). 359 | .TP 360 | \fBClient\fR value 361 | Override the global 362 | .I Client 363 | time-out value. 364 | .TP 365 | \fBCheckURL\fR "pattern to match" 366 | Define a pattern that must be matched by each request sent to this 367 | listener. A request that does not match is considered to be illegal. 368 | By default 369 | .B Pound 370 | accepts all requests (i.e. the pattern is ".*"), but you are free to 371 | limit it to something more reasonable. Please note that this applies 372 | only to the request path - 373 | .B Pound 374 | will still check that the request is syntactically correct. 375 | .TP 376 | \fBErr414\fR "filename" 377 | A file with the text to be displayed if an Error 414 occurs. 378 | Default: "Request URI is too long.". 379 | .TP 380 | \fBErr500\fR "filename" 381 | A file with the text to be displayed if an Error 500 occurs. 382 | Default: "An internal server error occurred. Please try again later.". 383 | .TP 384 | \fBErr501\fR "filename" 385 | A file with the text to be displayed if an Error 501 occurs. 386 | Default: "This method may not be used.". 387 | .TP 388 | \fBErr503\fR "filename" 389 | A file with the text to be displayed if an Error 503 occurs. 390 | Default: "The service is not available. Please try again later.". 391 | .TP 392 | \fBMaxRequest\fR nnn 393 | Request maximal size. All requests will be limited to these many bytes. If 394 | a request contains more data than allowed an error 414 is returned. Default: 395 | unlimited. 396 | .TP 397 | \fBHeadRemove\fR "header pattern" 398 | Remove certain headers from the incoming requests. All occurences of the 399 | matching specified header will be removed. Please note that this filtering 400 | is done prior to other checks (such as \fIHeadRequire\fR or \fIHeadDeny\fR), 401 | so you should not try to check for these headers in later matches. Multiple 402 | directives may be specified in order to remove more than one header, and 403 | the header itself may be a regular pattern (though this should be used with 404 | caution). 405 | .TP 406 | \fBAddHeader\fR "header: to add" 407 | Add the defined header to the request passed to the back-end server. The header 408 | is added verbatim. 409 | .TP 410 | \fBRewriteLocation\fR 0|1|2 411 | If 1 force 412 | .B Pound 413 | to change the Location: and Content-location: headers in responses. If they 414 | point to the back-end itself or to the listener (but with the wrong protocol) 415 | the response will be changed to show the virtual host in the request. Default: 416 | 1 (active). If the value is set to 2 only the back-end address is compared; 417 | this is useful for redirecting a request to an HTTPS listener on 418 | the same server as the HTTP listener. 419 | .TP 420 | \fBRewriteDestination\fR 0|1 421 | If 1 force 422 | .B Pound 423 | to change the Destination: header in requests. The header is changed to point 424 | to the back-end itself with the correct protocol. Default: 0. 425 | .TP 426 | \fBLogLevel\fR value 427 | Override the global 428 | .I LogLevel 429 | value. 430 | .TP 431 | \fBService\fR [ "name" ] 432 | This defines a private service (see below for service definition syntax). This 433 | service will be used only by this listener. The service may be optionally 434 | named, with the name showing in the 435 | .I poundctl 436 | listings. 437 | .SH "HTTPS Listener" 438 | An HTTPS listener defines an address and port that 439 | .B Pound 440 | will listen on for HTTPS requests. All configuration directives enclosed 441 | between 442 | .I ListenHTTPS 443 | and 444 | .I End 445 | are specific to a single HTTPS listener. At the very least you must specify 446 | and address, a port and a server certificate for each listener. All directives 447 | defined for HTTP listeners are applicable to HTTPS listeners as well. The 448 | following additional directives are also available: 449 | .TP 450 | \fBCert\fR "certificate file" 451 | Specify the server certificate. The 452 | .I certificate file 453 | is the file containing the certificate, possibly a certificate chain and the signature 454 | for this server. This directive is 455 | .B mandatory 456 | for HTTPS listeners. 457 | .TP 458 | \fBClientCert\fR 0|1|2|3 depth 459 | Ask for the client's HTTPS certificate: 0 - don't ask (default), 1 - ask, 460 | 2 - ask and fail if no certificate was presented, 3 - ask but do not verify. 461 | .I depth 462 | is the depth of verification for a client certificate (up to 9). 463 | .TP 464 | \fBCiphers\fR "acceptable:cipher:list" 465 | This is the list of ciphers that will be accepted by the SSL connection; it is a 466 | string in the same format as in OpenSSL 467 | .I ciphers(1) 468 | and 469 | .I SSL_CTX_set_cipher_list(3). 470 | .TP 471 | \fBCAlist\fR "CAcert_file" 472 | Set the list of "trusted" CA's for this server. The CAcert_file is a file containing 473 | a sequence of CA certificates (PEM format). The names of the defined CA certificates 474 | will be sent to the client on connection. 475 | .TP 476 | \fBVerifyList\fR "Verify_file" 477 | Set the CA (Certificate Authority). The Verify_file is a file that contains the CA 478 | root certificates (in PEM format). 479 | .IP 480 | .IR "Please note": 481 | there is an important difference between the CAlist and the VerifyList. The 482 | CAlist tells the client (browser) which client certificates it should send. The 483 | VerifyList defines which CAs are actually used for the verification of the 484 | returned certificate. 485 | .TP 486 | \fBCRLlist\fR "CRL_file" 487 | Set the CRL (Certificate Revocation List) file. The CRL_file is a file that contains 488 | the CRLs (in PEM format). 489 | .TP 490 | \fBNoHTTPS11\fR 0|1|2 491 | Behave like an HTTP/1.0 server for HTTPS clients. If this value is 492 | 0 disable the check. If the value is 1 do not allow multiple 493 | requests on SSL connections. If the value is 2 (default) disable multiple 494 | requests on SSL connections only for MSIE clients. Required 495 | work-around for a bug in certain versions of IE. 496 | .SH "Service" 497 | A service is a definition of which back-end servers 498 | .B Pound 499 | will use to reply to incoming requests. A service may be defined as part 500 | of a listener (in which case it will be used only by that listener), or 501 | globally (which makes it available to all listeners). 502 | .B Pound 503 | will always try the private services in the order defined, followed by 504 | the global ones. 505 | .P 506 | All configuration directives enclosed between 507 | .I Service 508 | and 509 | .I End 510 | are specific to a single service. The following directives are available: 511 | .TP 512 | \fBURL\fR "pattern" 513 | Match the incoming request. If a request fails to match than this service 514 | will be skipped and next one tried. If all services fail to match 515 | .B Pound 516 | returns an error. You may define multiple 517 | .I URL 518 | conditions per service. If no 519 | .I URL 520 | was defined then all requests match. The matching is by default case-sensitive, 521 | but this can be overridden by specifying 522 | .B IgnoreCase 1 523 | .TP 524 | \fBIgnoreCase\fR 0|1 525 | Override the global 526 | .B IgnoreCase 527 | setting. 528 | .TP 529 | \fBHeadRequire\fR "pattern" 530 | The request must contain at least on header matching the given pattern. 531 | Multiple 532 | .I HeadRequire 533 | directives may be defined per service, in which case all of them must 534 | be satisfied. 535 | .TP 536 | \fBHeadDeny\fR "pattern" 537 | The request may 538 | .B not 539 | contain any header matching the given pattern. Multiple 540 | .I HeadDeny 541 | directives may be defined per service, in which case all of them must be satisfied. 542 | .IP 543 | .IR "Please note": 544 | if the listener defined a 545 | .I HeadRemove 546 | directive, the matching headers are removed 547 | .B before 548 | the service matching is attempted. 549 | .TP 550 | \fBDynScale\fR 0|1 551 | Enable or disable dynamic rescaling for the current service. This value will 552 | override the value globally defined. 553 | .TP 554 | \fBBackEnd\fR 555 | Directives enclosed between a 556 | .I BackEnd 557 | and 558 | the following 559 | .I End 560 | directives define a single back-end server (see below for details). You may define 561 | multiple back-ends per service, in which case 562 | .B Pound 563 | will attempt to load-balance between them. 564 | .TP 565 | \fBRedirect\fR [code] "url" 566 | This is a special type of back-end. Instead of sending the request to a back-end 567 | .B Pound 568 | replies immediately with a redirection to the given URL. You may define multiple 569 | redirectors in a service, as well as mixing them with regular back-ends. 570 | .IP 571 | The address the client is redirected to is determined by the actual 572 | .I url 573 | you specify: if it is a "pure" host (i.e. with no path) then the client will be 574 | redirected to the host you specified, with the original request path appended. If 575 | your 576 | .I url 577 | does contain a path then the request path is ignored. 578 | .IP 579 | Examples: if you specified 580 | .br 581 | 582 | .br 583 | Redirect "http://abc.example" 584 | .br 585 | 586 | .br 587 | and the client requested 588 | .I http://xyz/a/b/c 589 | then it will be redirected to 590 | .IR "http://abc.example/a/b/c", 591 | but if you specified 592 | .br 593 | 594 | .br 595 | Redirect "http://abc.example/index.html" 596 | .br 597 | 598 | .br 599 | it will be sent to 600 | .IR "http://abc.example/index.html". 601 | .IP 602 | .IR "Technical note": 603 | in an ideal world 604 | .B Pound 605 | should reply with a "307 Temporary Redirect" status. Unfortunately, that is not 606 | yet supported by all clients (in particular HTTP 1.0 ones), so 607 | .B Pound 608 | currently replies by default with a "302 Found" instead. You may override this 609 | behaviour by specifying the code to be used (301, 302 or 307). 610 | .TP 611 | \fBEmergency\fR 612 | Directives enclosed between an 613 | .I Emergency 614 | and 615 | the following 616 | .I End 617 | directives define an emergency back-end server (see below for details). You may define 618 | only one emergency server per service, which 619 | .B Pound 620 | will attempt to use if all backends are down. 621 | .TP 622 | \fBSession\fR 623 | Directives enclosed between a 624 | .I Session 625 | and 626 | the following 627 | .I End 628 | directives define a session-tracking mechanism for the current service. See below 629 | for details. 630 | .SH "BackEnd" 631 | A back-end is a definition of a single back-end server 632 | .B Pound 633 | will use to reply to incoming requests. All configuration directives enclosed between 634 | .I BackEnd 635 | and 636 | .I End 637 | are specific to a single service. The following directives are available: 638 | .TP 639 | \fBAddress\fR address 640 | The address that 641 | .B Pound 642 | will connect to. This can be a numeric IP address, or a symbolic host name 643 | that must be resolvable at run-time. If the name cannot be resolved to a valid 644 | address, 645 | .B Pound 646 | will assume that it represents the path for a Unix-domain socket. This is a 647 | .B mandatory 648 | parameter. 649 | .TP 650 | \fBPort\fR port 651 | The port number that 652 | .B Pound 653 | will connect to. This is a 654 | .B mandatory 655 | parameter for non Unix-domain back-ends. 656 | .TP 657 | \fBHTTPS\fR [ "cert" ] 658 | The back-end is using HTTPS. If the optional parameter 659 | .I cert 660 | is specified, 661 | .B Pound 662 | will present this certificate to the back-end. 663 | .TP 664 | \fBPriority\fR val 665 | The priority of this back-end (between 1 and 9, 5 is default). Higher priority 666 | back-ends will be used more often than lower priority ones, so you should 667 | define higher priorities for more capable servers. 668 | .TP 669 | \fBTimeOut\fR val 670 | Override the global 671 | .I TimeOut 672 | value. 673 | .TP 674 | \fBConnTO\fR val 675 | Override the global 676 | .I ConnTO 677 | value. 678 | .TP 679 | \fBHAport\fR [ address ] port 680 | A port (and optional address) to be used for server function checks. See below 681 | the "High Availability" section for a more detailed discussion. By default 682 | .B Pound 683 | uses the same address as the back-end server, but you may use a separate address 684 | if you wish. This directive applies only to non Unix-domain servers. 685 | .SH "Emergency" 686 | The emergency server will be used once all existing back-ends are "dead". 687 | All configuration directives enclosed between 688 | .I Emergency 689 | and 690 | .I End 691 | are specific to a single service. The following directives are available: 692 | .TP 693 | \fBAddress\fR address 694 | The address that 695 | .B Pound 696 | will connect to. This can be a numeric IP address, or a symbolic host name 697 | that must be resolvable at run-time. If the name cannot be resolved to a valid 698 | address, 699 | .B Pound 700 | will assume that it represents the path for a Unix-domain socket. This is a 701 | .B mandatory 702 | parameter. 703 | .TP 704 | \fBPort\fR port 705 | The port number that 706 | .B Pound 707 | will connect to. This is a 708 | .B mandatory 709 | parameter for non Unix-domain back-ends. 710 | .SH "Session" 711 | Defines how a service deals with possible HTTP sessions. All configuration 712 | directives enclosed between 713 | .I Session 714 | and 715 | .I End 716 | are specific to a single service. Once a sessions is identified, 717 | .B Pound 718 | will attempt to send all requests within that session to the same back-end 719 | server. 720 | .PP 721 | The following directives are available: 722 | .TP 723 | \fBType\fR IP|BASIC|URL|PARM|COOKIE|HEADER 724 | What kind of sessions are we looking for: IP (the client address), BASIC (basic 725 | authentication), URL (a request parameter), PARM (a URI parameter), COOKIE (a 726 | certain cookie), or HEADER (a certain request header). 727 | This is a 728 | .B mandatory 729 | parameter. 730 | .TP 731 | \fBTTL\fR seconds 732 | How long can a session be idle (in seconds). A session that has been idle for 733 | longer than the specified number of seconds will be discarded. 734 | This is a 735 | .B mandatory 736 | parameter. 737 | .TP 738 | \fBID\fR "name" 739 | The session identifier. This directive is permitted only for sessions of type 740 | URL (the name of the request parameter we need to track), COOKIE (the name of 741 | the cookie) and HEADER (the header name). 742 | .PP 743 | See below for some examples. 744 | .SH HIGH-AVAILABILITY 745 | .B Pound 746 | attempts to keep track of active back-end servers, and will temporarily disable 747 | servers that do not respond (though not necessarily dead: an overloaded server 748 | that 749 | .B Pound 750 | cannot establish a connection to will be considered dead). However, every 751 | .I Alive 752 | seconds, an attempt is made to connect to the dead servers in case they have become 753 | active again. If this attempt succeeds, connections will be initiated to them again. 754 | .PP 755 | In general it is a good idea to set this time interval as low as is consistent with 756 | your resources in order to benefit from resurected servers at the earliest possible 757 | time. The default value of 30 seconds is probably a good choice. 758 | .PP 759 | The clients that happen upon a dead backend server will just receive a 760 | .I "503 Service Unavailable" 761 | message. 762 | .PP 763 | The 764 | .I HAport 765 | parameter specifies an additional port (and optionally an address) 766 | that is used only for viability checks: if this port is specified in a 767 | .I BackEnd 768 | directive, 769 | .B Pound 770 | will attempt periodically (every 771 | .I Alive 772 | seconds) to connect to this port. If the port does not respond the server is considered dead. 773 | .B "It never makes sense to have the" 774 | .I HAport 775 | .B "identical to the main back-end port:" 776 | this would only generate extra, unncecessary activity (CPU, network traffic) for no good 777 | reason whatsoever. The 778 | .I HAport 779 | is meant for applications that offer an additional health monitoring port or for installations 780 | that wish to take servers off-line in a controlled manner. 781 | .PP 782 | By default the address of the 783 | .I HAport 784 | health monitor is the same as that of the 785 | back-end server. You may specify a different address though, for example if you have 786 | a monitoring program running on another host. 787 | .SH HTTPS HEADERS 788 | If a client browser connects to 789 | .B Pound 790 | via HTTPS and if it presents a client certificate 791 | .B Pound 792 | adds the following headers to the request it issues to the server: 793 | .TP 794 | \fBX-SSL-Subject\fR 795 | Details about the certificate owner. 796 | .TP 797 | \fBX-SSL-Issuer\fR 798 | Details about the certificate issuer (Certificate Authority). 799 | .TP 800 | \fBX-SSL-notBefore\fR 801 | Starting date of certificate validity. 802 | .TP 803 | \fBX-SSL-notAfter\fR 804 | Ending date of certificate validity. 805 | .TP 806 | \fBX-SSL-serial\fR 807 | Certificate serial number (decimal). 808 | .TP 809 | \fBX-SSL-cipher\fR 810 | The cipher currently in use. 811 | .TP 812 | \fBX-SSL-certificate\fR 813 | The full client certificate (PEM-format multi-line) 814 | .PP 815 | It is the application's responsibility to actually use these 816 | headers - Pound just passes this information without checking 817 | it in any way (except for signature and encryption correctness). 818 | .SH SECURITY 819 | .PP 820 | In general, 821 | .B Pound 822 | does not read or write to the hard-disk. The exceptions are reading the configuration file 823 | and (possibly) the server certificate file(s) and error message(s), which are opened read-only 824 | on startup, read, 825 | and closed, and the pid file which is opened on start-up, written to and immediately closed. 826 | Following this there is no disk access whatsoever, so using a RootJail directive is only 827 | for extra security bonus points. 828 | .PP 829 | .B Pound 830 | tries to sanitise all HTTP/HTTPS requests: the request itself, the headers and the contents 831 | are checked for conformance to the RFC's and only valid requests are passed to the back-end 832 | servers. This is not absolutely fool-proof - as the recent Apache problem with chunked 833 | transfers demonstrated. However, given the current standards, this is the best that can 834 | be done - HTTP is an inherently weak protocol. 835 | .SH ADDITIONAL NOTES 836 | .B Pound 837 | uses the system log for messages (default facility LOG_DAEMON). The format is very similar to 838 | other web servers, so that if you want to use a log tool: 839 | .TP 840 | fgrep pound /var/log/messages | your_log_tool 841 | .PP 842 | Translating HTTPS to HTTP is an iffy proposition: no client information is passed to 843 | the server itself (certificates, etc) and the backend server may be misled if it 844 | uses absolute URLs. A patch for \fIZope\fR is included in the distribution to address 845 | this issue - for other Web servers you are on your own. May the source be with you. 846 | .PP 847 | .B Pound 848 | deals with (and sanitizes) HTTP/1.1 requests. Thus even if you have an HTTP/1.0 server, 849 | a single connection to an HTTP/1.1 client is kept, while the connection to the back-end 850 | server is re-opened as necessary. 851 | .PP 852 | .B Pound 853 | attempts to resolve the names of the hosts that appear in various requests and/or responses. 854 | That means it need a functioning resolver of some kind (be it /etc/hosts, DNS or something 855 | else). 856 | .SH EXAMPLES 857 | To translate HTTPS requests to a local HTTP server (assuming your network address 858 | is 123.123.123.123): 859 | .IP 860 | ListenHTTPS 861 | .br 862 | Address 1.2.3.4 863 | .br 864 | Port 443 865 | .br 866 | Cert "/etc/pound/server.pem" 867 | .br 868 | 869 | .br 870 | Service 871 | .br 872 | BackEnd 873 | .br 874 | Address 127.0.0.1 875 | .br 876 | Port 80 877 | .br 878 | End 879 | .br 880 | End 881 | .br 882 | End 883 | .PP 884 | To distribute the HTTP/HTTPS requests to three Web servers, where the third one 885 | is a newer and faster machine: 886 | .IP 887 | ListenHTTP 888 | .br 889 | Address 123.123.123.123 890 | .br 891 | Port 80 892 | .br 893 | End 894 | .br 895 | ListenHTTPS 896 | .br 897 | Address 1.2.3.4 898 | .br 899 | Port 443 900 | .br 901 | Cert "/etc/pound/server.pem" 902 | .br 903 | End 904 | .br 905 | 906 | .br 907 | Service 908 | .br 909 | BackEnd 910 | .br 911 | Address 192.168.0.10 912 | .br 913 | Port 80 914 | .br 915 | End 916 | .br 917 | BackEnd 918 | .br 919 | Address 192.168.0.11 920 | .br 921 | Port 80 922 | .br 923 | End 924 | .br 925 | BackEnd 926 | .br 927 | Address 192.168.0.12 928 | .br 929 | Port 80 930 | .br 931 | Priority 3 932 | .br 933 | End 934 | .br 935 | End 936 | .PP 937 | To separate between image requests and other Web content and send all requests 938 | for a specific URL to a secure server: 939 | .IP 940 | ListenHTTP 941 | .br 942 | Address 123.123.123.123 943 | .br 944 | Port 80 945 | .br 946 | End 947 | .br 948 | 949 | .br 950 | # Images server(s) 951 | .br 952 | Service 953 | .br 954 | URL ".*.(jpg|gif)" 955 | .br 956 | BackEnd 957 | .br 958 | Address 192.168.0.12 959 | .br 960 | Port 80 961 | .br 962 | End 963 | .br 964 | End 965 | .br 966 | 967 | .br 968 | # redirect all requests for /forbidden 969 | .br 970 | Service 971 | .br 972 | Url "/forbidden.*" 973 | .br 974 | Redirect "https://xyzzy.com" 975 | .br 976 | End 977 | .br 978 | 979 | .br 980 | # Catch-all server(s) 981 | .br 982 | Service 983 | .br 984 | BackEnd 985 | .br 986 | Address 192.168.0.10 987 | .br 988 | Port 80 989 | .br 990 | End 991 | .br 992 | BackEnd 993 | .br 994 | Address 192.168.0.11 995 | .br 996 | Port 80 997 | .br 998 | End 999 | .br 1000 | Session 1001 | .br 1002 | Type BASIC 1003 | .br 1004 | TTL 300 1005 | .br 1006 | End 1007 | .br 1008 | End 1009 | .PP 1010 | Here is a more complex example: assume your static images (GIF/JPEG) are to be served 1011 | from a single back-end 192.168.0.10. In addition, 192.168.0.11 is to do the 1012 | hosting for www.myserver.com with URL-based sessions, and 192.168.0.20 (a 1GHz PIII) 1013 | and 192.168.0.21 (800Mhz Duron) are for all other requests (cookie-based sessions). 1014 | The logging will be done by the back-end servers. The configuration file may look like this: 1015 | .IP 1016 | User "nobody" 1017 | .br 1018 | Group "nogroup" 1019 | .br 1020 | RootJail "/var/pound/jail" 1021 | .br 1022 | Alive 60 1023 | .br 1024 | LogLevel 0 1025 | .br 1026 | 1027 | .br 1028 | # Main listening ports 1029 | .br 1030 | ListenHTTP 1031 | .br 1032 | Address 1.2.3.4 1033 | .br 1034 | Port 80 1035 | .br 1036 | Client 10 1037 | .br 1038 | End 1039 | .br 1040 | ListenHTTPS 1041 | .br 1042 | Address 1.2.3.4 1043 | .br 1044 | Port 443 1045 | .br 1046 | Cert "/etc/pound/pound.pem" 1047 | .br 1048 | Client 20 1049 | .br 1050 | End 1051 | .br 1052 | 1053 | .br 1054 | # Image server 1055 | .br 1056 | Service 1057 | .br 1058 | URL ".*.(jpg|gif)" 1059 | .br 1060 | BackEnd 1061 | .br 1062 | Address 192.168.0.10 1063 | .br 1064 | Port 80 1065 | .br 1066 | End 1067 | .br 1068 | End 1069 | .br 1070 | 1071 | .br 1072 | # Virtual host www.myserver.com 1073 | .br 1074 | Service 1075 | .br 1076 | URL ".*sessid=.*" 1077 | .br 1078 | HeadRequire "Host:.*www.myserver.com.*" 1079 | .br 1080 | BackEnd 1081 | .br 1082 | Address 192.168.0.11 1083 | .br 1084 | Port 80 1085 | .br 1086 | End 1087 | .br 1088 | Session 1089 | .br 1090 | Type URL 1091 | .br 1092 | ID "sessid" 1093 | .br 1094 | TTL 120 1095 | .br 1096 | End 1097 | .br 1098 | End 1099 | .br 1100 | 1101 | .br 1102 | # Everybody else 1103 | .br 1104 | Service 1105 | .br 1106 | BackEnd 1107 | .br 1108 | Address 192.168.0.20 1109 | .br 1110 | Port 80 1111 | .br 1112 | Priority 5 1113 | .br 1114 | End 1115 | .br 1116 | BackEnd 1117 | .br 1118 | Address 192.168.0.21 1119 | .br 1120 | Port 80 1121 | .br 1122 | Priority 4 1123 | .br 1124 | End 1125 | .br 1126 | Session 1127 | .br 1128 | Type COOKIE 1129 | .br 1130 | ID "userid" 1131 | .br 1132 | TTL 180 1133 | .br 1134 | End 1135 | .br 1136 | End 1137 | .br 1138 | .SH FILES 1139 | .TP 1140 | \fI/var/run/pound.nnn\fR 1141 | this is where 1142 | .B Pound 1143 | will attempt to record its process id. 1144 | .TP 1145 | \fI/usr/local/etc/pound.cfg\fR 1146 | the default configuration file (the location may be changed when compiling - see the 1147 | F_CONF flag in the Makefile). 1148 | .TP 1149 | \fI/usr/local/etc/pound/cert.pem\fR 1150 | the certificate file(s) for HTTPS. The location must be defined in the configuration 1151 | file - this is only a suggestion. The file must contain a PEM-encoded certificate, 1152 | optionally a certificate chain from a known Certificate Authority to your server certificate 1153 | and a PEM-encoded private key (not password protected). See 1154 | .I OpenSSL(1) 1155 | for details. This file should be well protected, lest someone gets your server 1156 | private key. 1157 | .SH AUTHOR 1158 | Written by Robert Segall, Apsis GmbH. 1159 | .SH "REPORTING BUGS" 1160 | Report bugs to . 1161 | .SH COPYRIGHT 1162 | Copyright \(co 2002-2010 Apsis GmbH. 1163 | .br 1164 | This is free software; see the source for copying conditions. There is NO 1165 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1166 | --------------------------------------------------------------------------------