Re: fancy redirects / 404 passthrough

Ingo Molnar <[email protected]>
Newsgroups gmane.network.tux
Message-ID <Pine.LNX.4.56.0310291822430.20548@earth>
> ie. you want to cache those pages via actual 'Showpage.php?user=name'
> files [and have them served as static pages by Tux], and you want Tux to
> fall back to Apache only if these files do not exist?

in this case you might want to try the attached patch. It introduces two 
levels to /proc/sys/net/tux/ignore_query:

	value 0: current, unchanged behavior

	value 1: treat '?' as part of the filename

	value 2: ignore the '?' and all characters up to the next 
		 whitespace

ie. with a value of '1', http://server/name?query will be looked up under
docroot, as the literal filename 'name?query'. With value 2, the query is 
ignored and only 'name' is looked up (and returned as a static page).

does this get you closer to a solution?

	Ingo

--- linux/include/linux/sysctl.h.orig	
+++ linux/include/linux/sysctl.h	
@@ -562,6 +562,7 @@ enum {
 	NET_TUX_MAX_HEADER_LEN		= 42,
 	NET_TUX_404_PAGE		= 43,
 	NET_TUX_MAX_KEEPALIVES		= 44,
+	NET_TUX_IGNORE_QUERY		= 45,
 };
 
 /* /proc/sys/net/khttpd/ */
--- linux/include/net/tux.h.orig	
+++ linux/include/net/tux.h	
@@ -715,6 +715,7 @@ extern unsigned int tux_cgi_cpu_mask;
 extern tux_proto_t tux_proto_http;
 extern tux_proto_t tux_proto_ftp;
 extern unsigned int tux_all_userspace;
+extern unsigned int tux_ignore_query;
 extern unsigned int tux_redirect_logging;
 extern unsigned int tux_referer_logging;
 extern unsigned int tux_log_incomplete;
--- linux/net/tux/proc.c.orig	
+++ linux/net/tux/proc.c	
@@ -60,6 +60,7 @@ unsigned int tux_cgi_inherit_cpu = 0;
 unsigned int tux_cgi_cpu_mask = ~0;
 unsigned int tux_zerocopy_header = 1;
 unsigned int tux_max_free_requests = 1000;
+unsigned int tux_ignore_query = 0;
 unsigned int tux_all_userspace = 0;
 unsigned int tux_redirect_logging = 1;
 unsigned int tux_max_header_len = 3000;
@@ -693,6 +694,18 @@ static ctl_table tux_table[] = {
 		NULL,
 		NULL
 	},
+	{	NET_TUX_IGNORE_QUERY,
+		"ignore_query",
+		&tux_ignore_query,
+		sizeof(int),
+		0644,
+		NULL,
+		proc_dointvec,
+		&sysctl_intvec,
+		NULL,
+		NULL,
+		NULL
+	},
 	{	NET_TUX_REFERER_LOGGING,
 		"referer_logging",
 		&tux_referer_logging,
--- linux/net/tux/proto_http.c.orig	
+++ linux/net/tux/proto_http.c	
@@ -220,7 +220,7 @@ int parse_http_message (tux_req_t *req, 
 			}
 
 			PRINT_MESSAGE_LEFT;
-			if (c == ' ' || c == '?' || c == '\r' || c == '\n')
+			if (c == ' ' || ((c == '?') && (tux_ignore_query != 1)) || c == '\r' || c == '\n')
 				break;
 			if (c == '#')
 				GOTO_REDIR;
@@ -319,8 +319,13 @@ continue_parsing:
 			if (c == '#')
 				GOTO_REDIR;
 		}
-		query_len = curr-query-1;
-		req->query_len = query_len;
+
+		if (unlikely(tux_ignore_query == 2))
+			req->query_str = NULL;
+		else {
+			query_len = curr-query-1;
+			req->query_len = query_len;
+		}
 	}
 	if (req->query_len)
 		Dprintk("got query string %s (%d)\n", req->query_str, req->query_len);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.