Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Cherokee: commits

[3769] cherokee/trunk: Adds a new option to allow the reverse proxy plug-in to replace the

 

 

Cherokee commits RSS feed   Index | Next | Previous | View Threaded


cherokee at cherokee-project

Oct 31, 2009, 3:47 PM

Post #1 of 1 (37 views)
Permalink
[3769] cherokee/trunk: Adds a new option to allow the reverse proxy plug-in to replace the

Revision: 3769
http://svn.cherokee-project.com/changeset/3769
Author: alo
Date: 2009-10-31 23:47:41 +0100 (Sat, 31 Oct 2009)

Log Message:
-----------
Adds a new option to allow the reverse proxy plug-in to replace the
"Server:" header sent by the back-end client. This patch implements
both the admin and server side of things.

Modified Paths:
--------------
cherokee/trunk/admin/ModuleProxy.py
cherokee/trunk/cherokee/handler_proxy.c
cherokee/trunk/cherokee/handler_proxy.h

Modified: cherokee/trunk/admin/ModuleProxy.py
===================================================================
--- cherokee/trunk/admin/ModuleProxy.py 2009-10-31 19:35:55 UTC (rev 3768)
+++ cherokee/trunk/admin/ModuleProxy.py 2009-10-31 22:47:41 UTC (rev 3769)
@@ -13,6 +13,7 @@
NOTE_REUSE_MAX = N_("Maximum number of connection per server that the proxy can try to keep opened.")
NOTE_ALLOW_KEEPALIVE = N_("Allow the server to use Keep-alive connections with the back-end servers.")
NOTE_PRESERVE_HOST = N_("Preserve the original \"Host:\" header sent by the client. (Default No)")
+NOTE_PRESERVE_SERVER = N_("Preserve the \"Server:\" header sent by the back-end server. (Default No)")

HELPS = [
('modules_handlers_proxy', N_("Reverse Proxy"))
@@ -23,6 +24,7 @@
'balancer',
'in_allow_keepalive',
'in_preserve_host',
+ 'out_preserve_server',
'in_header_add', 'out_header_add',
'in_header_hide', 'out_header_hide',
'in_rewrite_request', 'out_rewrite_request'
@@ -56,9 +58,10 @@

def _render_general (self):
table = TableProps()
- self.AddPropEntry (table, _('Reuse connections'), '%s!reuse_max'%(self._prefix), _(NOTE_REUSE_MAX))
- self.AddPropCheck (table, _('Allow Keepalive'), '%s!in_allow_keepalive'%(self._prefix), True, _(NOTE_ALLOW_KEEPALIVE))
- self.AddPropCheck (table, _('Preserve Host header'), '%s!in_preserve_host'%(self._prefix), False, _(NOTE_PRESERVE_HOST))
+ self.AddPropEntry (table, _('Reuse connections'), '%s!reuse_max'%(self._prefix), _(NOTE_REUSE_MAX))
+ self.AddPropCheck (table, _('Allow Keepalive'), '%s!in_allow_keepalive'%(self._prefix), True, _(NOTE_ALLOW_KEEPALIVE))
+ self.AddPropCheck (table, _('Preserve Host header'), '%s!in_preserve_host'%(self._prefix), False, _(NOTE_PRESERVE_HOST))
+ self.AddPropCheck (table, _('Preserve Server header'), '%s!out_preserve_server'%(self._prefix), False, _(NOTE_PRESERVE_SERVER))
return str(table)

def _render_request (self):

Modified: cherokee/trunk/cherokee/handler_proxy.c
===================================================================
--- cherokee/trunk/cherokee/handler_proxy.c 2009-10-31 19:35:55 UTC (rev 3768)
+++ cherokee/trunk/cherokee/handler_proxy.c 2009-10-31 22:47:41 UTC (rev 3769)
@@ -118,10 +118,11 @@
cherokee_module_props_init_base (MODULE_PROPS(n),
MODULE_PROPS_FREE(props_free));

- n->balancer = NULL;
- n->reuse_max = DEFAULT_REUSE_MAX;
- n->in_allow_keepalive = true;
- n->in_preserve_host = false;
+ n->balancer = NULL;
+ n->reuse_max = DEFAULT_REUSE_MAX;
+ n->in_allow_keepalive = true;
+ n->in_preserve_host = false;
+ n->out_preserve_server = false;

INIT_LIST_HEAD (&n->in_request_regexs);
INIT_LIST_HEAD (&n->in_headers_add);
@@ -159,6 +160,9 @@
} else if (equal_buf_str (&subconf->key, "in_preserve_host")) {
props->in_preserve_host = !! atoi (subconf->val.buf);

+ } else if (equal_buf_str (&subconf->key, "out_preserve_server")) {
+ props->out_preserve_server = !! atoi (subconf->val.buf);
+
} else if (equal_buf_str (&subconf->key, "in_header_hide")) {
cherokee_config_node_foreach (j, subconf) {
cherokee_avl_add (&props->in_headers_hide,
@@ -999,6 +1003,14 @@

HANDLER(hdl)->support |= hsupport_length;

+ } else if ((! props->out_preserve_server) &&
+ (strncasecmp (begin, "Server:", 7) == 0)) {
+
+ cherokee_buffer_add_str (buf_out, "Server: ");
+ cherokee_buffer_add_buffer (buf_out, &CONN_BIND(conn)->server_string);
+ cherokee_buffer_add_str (buf_out, CRLF);
+ goto next;
+
} else if (strncasecmp (begin, "Location:", 9) == 0) {
cherokee_buffer_t *tmp1 = &HANDLER_THREAD(hdl)->tmp_buf1;
cherokee_buffer_t *tmp2 = &HANDLER_THREAD(hdl)->tmp_buf2;

Modified: cherokee/trunk/cherokee/handler_proxy.h
===================================================================
--- cherokee/trunk/cherokee/handler_proxy.h 2009-10-31 19:35:55 UTC (rev 3768)
+++ cherokee/trunk/cherokee/handler_proxy.h 2009-10-31 22:47:41 UTC (rev 3769)
@@ -66,6 +66,7 @@
cherokee_avl_t out_headers_hide;
cherokee_list_t out_headers_add;
cherokee_list_t out_request_regexs;
+ cherokee_boolean_t out_preserve_server;
} cherokee_handler_proxy_props_t;

typedef struct {

Cherokee commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.