75 lines
2.7 KiB
Diff
75 lines
2.7 KiB
Diff
diff -r e24850f69497 src/http/ngx_http.c
|
|
--- a/src/http/ngx_http.c Tue Jan 22 11:49:18 2008 +0100
|
|
+++ b/src/http/ngx_http.c Sun Feb 10 11:14:22 2008 +0100
|
|
@@ -363,6 +363,22 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma
|
|
hk->value = header;
|
|
}
|
|
|
|
+ if (cmcf->use_x_forwarded_host) {
|
|
+ /* Use the X-Forwarded-Host instead of the Host header */
|
|
+ ngx_http_header_t *header = ngx_palloc(cf->pool, sizeof(ngx_http_header_t));
|
|
+
|
|
+ header->name.data = (u_char *) "X-Forwarded-Host";
|
|
+ header->name.len = sizeof("X-Forwarded-Host") - 1;
|
|
+ header->offset = offsetof(ngx_http_headers_in_t, host);
|
|
+ header->handler = ngx_http_headers_in[0].handler;
|
|
+
|
|
+ hk = headers_in.elts;
|
|
+
|
|
+ hk->key = header->name;
|
|
+ hk->key_hash = ngx_hash_key_lc(header->name.data, header->name.len);
|
|
+ hk->value = header;
|
|
+ }
|
|
+
|
|
hash.hash = &cmcf->headers_in_hash;
|
|
hash.key = ngx_hash_key_lc;
|
|
hash.max_size = 512;
|
|
diff -r e24850f69497 src/http/ngx_http_core_module.c
|
|
--- a/src/http/ngx_http_core_module.c Tue Jan 22 11:49:18 2008 +0100
|
|
+++ b/src/http/ngx_http_core_module.c Sun Feb 10 11:14:22 2008 +0100
|
|
@@ -92,6 +92,13 @@ static ngx_conf_enum_t ngx_http_core_re
|
|
|
|
static ngx_command_t ngx_http_core_commands[] = {
|
|
|
|
+ { ngx_string("use_x_forwarded_host"),
|
|
+ NGX_HTTP_MAIN_CONF|NGX_CONF_FLAG,
|
|
+ ngx_conf_set_flag_slot,
|
|
+ NGX_HTTP_MAIN_CONF_OFFSET,
|
|
+ offsetof(ngx_http_core_main_conf_t, use_x_forwarded_host),
|
|
+ NULL },
|
|
+
|
|
{ ngx_string("variables_hash_max_size"),
|
|
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
|
|
ngx_conf_set_num_slot,
|
|
@@ -2144,6 +2151,8 @@ ngx_http_core_create_main_conf(ngx_conf_
|
|
return NGX_CONF_ERROR;
|
|
}
|
|
|
|
+ cmcf->use_x_forwarded_host = NGX_CONF_UNSET;
|
|
+
|
|
cmcf->server_names_hash_max_size = NGX_CONF_UNSET_UINT;
|
|
cmcf->server_names_hash_bucket_size = NGX_CONF_UNSET_UINT;
|
|
|
|
@@ -2159,6 +2168,10 @@ ngx_http_core_init_main_conf(ngx_conf_t
|
|
{
|
|
ngx_http_core_main_conf_t *cmcf = conf;
|
|
|
|
+ if (cmcf->use_x_forwarded_host == NGX_CONF_UNSET) {
|
|
+ cmcf->use_x_forwarded_host = 0;
|
|
+ }
|
|
+
|
|
if (cmcf->server_names_hash_max_size == NGX_CONF_UNSET_UINT) {
|
|
cmcf->server_names_hash_max_size = 512;
|
|
}
|
|
diff -r e24850f69497 src/http/ngx_http_core_module.h
|
|
--- a/src/http/ngx_http_core_module.h Tue Jan 22 11:49:18 2008 +0100
|
|
+++ b/src/http/ngx_http_core_module.h Sun Feb 10 11:14:22 2008 +0100
|
|
@@ -99,6 +99,7 @@ typedef struct {
|
|
|
|
ngx_array_t variables; /* ngx_http_variable_t */
|
|
|
|
+ ngx_flag_t use_x_forwarded_host;
|
|
ngx_uint_t server_names_hash_max_size;
|
|
ngx_uint_t server_names_hash_bucket_size;
|
|
|