Browse Source

[pound] Updated (2.2.8 -> 2.4)

early
Alejandro Mery 17 years ago
parent
commit
317d0d9c8c
  1. 205
      network/pound/pound-2.3.2-custom-redirect.patch
  2. 2
      network/pound/pound.conf
  3. 7
      network/pound/pound.desc

205
network/pound/pound-2.3.2-custom-redirect.patch

@ -1,205 +0,0 @@
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../pound/pound-2.3.2-custom-redirect.patch
# Copyright (C) 2008 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---
Author: Chris Barnett <barn3y(at)gmail.com>
Initial Package Version: 2.3.2
Origin: http://www.apsis.ch/pound/pound_list/archive/2007/2007-09/1190613609000#1190613609000
Description: This patch adds the capability to configure 301 or 307 redirects.
Usage Information:
You can force a 301 Moved Permanently redirect like this:
ListenHTTP
Address 0.0.0.0
Port 80
Service
HeadRequire "Host: .*www.server0.com.*"
Redirect 301 "http://www.server1.com"
End
End
You can force a 302 Found or 307 Temporary Redirect in the same way.
The existing Redirect syntax still works as expected:
ListenHTTP
Address 0.0.0.0
Port 80
Service
HeadRequire "Host: .*www.server0.com.*"
Redirect "http://www.server1.com"
End
End
Will use a 302 Found redirect.
diff -Naur Pound-2.3.2/config.c Pound-2.3.2-custom-redirect/config.c
--- Pound-2.3.2/config.c 2007-05-18 18:34:53.000000000 +1000
+++ Pound-2.3.2-custom-redirect/config.c 2007-09-24 14:51:40.000000000 +1000
@@ -425,7 +425,9 @@
be->alive = 1;
pthread_mutex_init(&res->mut, NULL);
lin[matches[1].rm_eo] = '\0';
- if((be->url = strdup(lin + matches[1].rm_so)) == NULL) {
+ be->redir_type = atoi(lin + matches[1].rm_so);
+ lin[matches[3].rm_eo] = '\0';
+ if((be->url = strdup(lin + matches[3].rm_so)) == NULL) {
logmsg(LOG_ERR, "line %d: Redirector config: out of memory - aborted", n_lin);
exit(1);
}
@@ -1083,7 +1085,7 @@
|| regcomp(&TimeOut, "^[ \t]*TimeOut[ \t]+([1-9][0-9]*)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
|| regcomp(&HAport, "^[ \t]*HAport[ \t]+([1-9][0-9]*)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
|| regcomp(&HAportAddr, "^[ \t]*HAport[ \t]+([^ \t]+)[ \t]+([1-9][0-9]*)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
- || regcomp(&Redirect, "^[ \t]*Redirect[ \t]+\"(.+)\"[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
+ || regcomp(&Redirect, "^[ \t]*Redirect[ \t]+((301|302|307)[ \t]+)?\"(.+)\"[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
|| regcomp(&Session, "^[ \t]*Session[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
|| regcomp(&Type, "^[ \t]*Type[ \t]+([^ \t]+)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
|| regcomp(&TTL, "^[ \t]*TTL[ \t]+([1-9][0-9]*)[ \t]*$", REG_ICASE | REG_NEWLINE | REG_EXTENDED)
diff -Naur Pound-2.3.2/http.c Pound-2.3.2-custom-redirect/http.c
--- Pound-2.3.2/http.c 2007-05-18 18:34:53.000000000 +1000
+++ Pound-2.3.2-custom-redirect/http.c 2007-09-24 15:07:20.000000000 +1000
@@ -52,23 +52,32 @@
* Reply with a redirect
*/
static void
-redirect_reply(BIO *const c, const char *url)
+redirect_reply(BIO *const c, const int redir_type, const char *url)
{
char rep[MAXBUF], cont[MAXBUF];
+ char *type_str;
snprintf(cont, sizeof(cont),
"<html><head><title>Redirect</title></head><body><h1>Redirect</h1><p>You should go to <a href=\"%s\">%s</a></p></body></html>",
url, url);
- /*
- * This really should be 307, but some HTTP/1.0 clients do not understand that, so we use 302
+
+ switch(redir_type) {
+ case 301:
+ type_str = "301 Moved Permanently";
+ break;
+
+ case 307:
+ type_str = "307 Temporary Redirect";
+ break;
+
+ default:
+ type_str = "302 Found";
+ break;
+ }
snprintf(rep, sizeof(rep),
- "HTTP/1.0 307 Temporary Redirect\r\nLocation: %s\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n",
- url, strlen(cont));
- */
- snprintf(rep, sizeof(rep),
- "HTTP/1.0 302 Found\r\nLocation: %s\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n",
- url, strlen(cont));
+ "HTTP/1.0 %s\r\nLocation: %s\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n",
+ type_str, url, strlen(cont));
BIO_write(c, rep, strlen(rep));
BIO_write(c, cont, strlen(cont));
BIO_flush(c);
@@ -996,7 +1005,7 @@
snprintf(buf, sizeof(buf) - 1, "%s%s", cur_backend->url, url);
else
strncpy(buf, cur_backend->url, sizeof(buf) - 1);
- redirect_reply(cl, buf);
+ redirect_reply(cl, cur_backend->redir_type, buf);
addr2str(caddr, MAXBUF - 1, &from_host);
switch(lstn->log_level) {
case 0:
diff -Naur Pound-2.3.2/pound.8 Pound-2.3.2-custom-redirect/pound.8
--- Pound-2.3.2/pound.8 2007-05-18 18:34:53.000000000 +1000
+++ Pound-2.3.2-custom-redirect/pound.8 2007-09-24 15:06:14.000000000 +1000
@@ -544,11 +544,13 @@
.B Pound
will attempt to load-balance between them.
.TP
-\fBRedirect\fR "url"
+\fBRedirect\fR [301|302|307] "url"
This is a special type of back-end. Instead of sending the request to a back-end
.B Pound
-replies immediately with a redirection to the given URL. You may define multiple
-redirectors in a service, as well as mixing them with regular back-ends.
+replies immediately with a redirection to the given URL. You may specify the type
+of redirection used: 301 Moved Permanently, 302 Found (default if none specified),
+or 307 Temporary Redirect. You may define multiple redirectors in a service, as
+well as mixing them with regular back-ends.
.IP
The address the client is redirected to is determined by the actual
.I url
@@ -562,7 +564,7 @@
.br
.br
- Redirect "http://abc.example"
+ Redirect 307 "http://abc.example"
.br
.br
@@ -574,7 +576,7 @@
.br
.br
- Redirect "http://abc.example/index.html"
+ Redirect 307 "http://abc.example/index.html"
.br
.br
@@ -582,12 +584,11 @@
.IR "http://abc.example/index.html".
.IP
.IR "Technical note":
-in an ideal world
+Ideally, "307 Temporary Redirect" should be used instead of "302 Found".
+Unfortunately, that is not yet supported by all clients (in particular
+HTTP 1.0 ones), so
.B Pound
-should reply with a "307 Temporary Redirect" status. Unfortunately, that is not
-yet supported by all clients (in particular HTTP 1.0 ones), so
-.B Pound
-currently replies with a "302 Found" instead.
+currently defaults to "302 Found" instead.
.TP
\fBEmergency\fR
Directives enclosed between an
@@ -940,7 +941,7 @@
.br
Url "/forbidden.*"
.br
- Redirect "https://xyzzy.com"
+ Redirect 302 "https://xyzzy.com"
.br
End
.br
diff -Naur Pound-2.3.2/pound.h Pound-2.3.2-custom-redirect/pound.h
--- Pound-2.3.2/pound.h 2007-05-18 18:34:53.000000000 +1000
+++ Pound-2.3.2-custom-redirect/pound.h 2007-09-24 14:05:30.000000000 +1000
@@ -288,7 +288,8 @@
int priority; /* priority */
int to;
struct sockaddr_in HA; /* HA address & port */
- char *url; /* for redirectors */
+ char *url; /* (URL for redirectors) */
+ int redir_type; /* redirect type (for redirectors) */
int redir_req; /* the redirect should include the request path */
pthread_mutex_t mut; /* mutex for this back-end */
int n_requests; /* number of requests seen */

2
network/pound/pound.conf

@ -2,6 +2,7 @@
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../pound/pound.conf
# Copyright (C) 2008 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
#
# More information can be found in the files COPYING and README.
@ -11,6 +12,7 @@
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
if [ $prefix_auto = 1 ] ; then
if [ "$SDECFG_PKG_POUND_PREFIX" ] ; then
prefix="$SDECFG_PKG_POUND_PREFIX"

7
network/pound/pound.desc

@ -2,7 +2,7 @@
[COPY] This copyright note is auto-generated by ./scripts/Create-CopyPatch.
[COPY]
[COPY] Filename: package/.../pound/pound.desc
[COPY] Copyright (C) 2006 - 2007 The OpenSDE Project
[COPY] Copyright (C) 2006 - 2008 The OpenSDE Project
[COPY] Copyright (C) 2004 - 2006 The T2 SDE Project
[COPY]
[COPY] More information can be found in the files COPYING and README.
@ -12,6 +12,7 @@
[COPY] the Free Software Foundation; version 2 of the License. A copy of the
[COPY] GNU General Public License can be found in the file COPYING.
[COPY] --- SDE-COPYRIGHT-NOTE-END ---
[I] Pound - Reverse-Proxy and Loadbalancer
[T] The Pound program is a reverse proxy, load balancer and HTTPS front-end
@ -29,7 +30,7 @@
[L] OpenSource
[S] Stable
[V] 2.2.8
[V] 2.4
[P] X -----5---9 200.400
[D] 1806148421 Pound-2.2.8.tgz http://www.apsis.ch/pound/
[D] 1606040447 Pound-2.4.tgz http://www.apsis.ch/pound/

Loading…
Cancel
Save