summaryrefslogtreecommitdiffhomepage
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-11-02 15:24:02 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-11-02 15:24:02 +0000
commit72e928755ba63b803c0b2478f6d8d1e792e95b86 (patch)
tree48354712b370bdfccd1d22824a6f2ddea5ca8443 /src/http
parent1d52beba7339a6edf235a2160bc20fc466e1823a (diff)
downloadnginx-72e928755ba63b803c0b2478f6d8d1e792e95b86.tar.gz
nginx-72e928755ba63b803c0b2478f6d8d1e792e95b86.tar.bz2
proxy_bind, fastcgi_bind, and memcached_bind
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c7
-rw-r--r--src/http/modules/ngx_http_memcached_module.c7
-rw-r--r--src/http/modules/ngx_http_proxy_module.c7
-rw-r--r--src/http/ngx_http_upstream.c27
-rw-r--r--src/http/ngx_http_upstream.h4
5 files changed, 52 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index a4a62e4cc..ba79cea0f 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -240,6 +240,13 @@ static ngx_command_t ngx_http_fastcgi_commands[] = {
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.ignore_client_abort),
NULL },
+ { ngx_string("fastcgi_bind"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_http_upsteam_bind_set_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_fastcgi_loc_conf_t, upstream.local),
+ NULL },
+
{ ngx_string("fastcgi_connect_timeout"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_msec_slot,
diff --git a/src/http/modules/ngx_http_memcached_module.c b/src/http/modules/ngx_http_memcached_module.c
index 6cf58815b..92052153d 100644
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -63,6 +63,13 @@ static ngx_command_t ngx_http_memcached_commands[] = {
0,
NULL },
+ { ngx_string("memcached_bind"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_http_upsteam_bind_set_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_memcached_loc_conf_t, upstream.local),
+ NULL },
+
{ ngx_string("memcached_connect_timeout"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_msec_slot,
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index 88530e1db..8f169fe43 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -229,6 +229,13 @@ static ngx_command_t ngx_http_proxy_commands[] = {
offsetof(ngx_http_proxy_loc_conf_t, upstream.ignore_client_abort),
NULL },
+ { ngx_string("proxy_bind"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_http_upsteam_bind_set_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_proxy_loc_conf_t, upstream.local),
+ NULL },
+
{ ngx_string("proxy_connect_timeout"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_msec_slot,
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index b95db57a7..a04aad323 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -479,6 +479,8 @@ ngx_http_upstream_init_request(ngx_http_request_t *r)
return;
}
+ u->peer.local = u->conf->local;
+
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
u->output.alignment = clcf->directio_alignment;
@@ -4196,6 +4198,31 @@ ngx_http_upstream_add(ngx_conf_t *cf, ngx_url_t *u, ngx_uint_t flags)
}
+char *
+ngx_http_upsteam_bind_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf)
+{
+ char *p = conf;
+
+ ngx_str_t *value;
+ ngx_addr_t **paddr;
+
+ paddr = (ngx_addr_t **) (p + cmd->offset);
+
+ value = cf->args->elts;
+
+ *paddr = ngx_parse_addr(cf->pool, &value[1]);
+ if (*paddr) {
+ return NGX_CONF_OK;
+ }
+
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid address \"%V\"", &value[1]);
+
+ return NGX_CONF_ERROR;
+}
+
+
ngx_int_t
ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
index 2d3bc2000..09fab00e6 100644
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -152,6 +152,8 @@ typedef struct {
ngx_array_t *hide_headers;
ngx_array_t *pass_headers;
+ ngx_addr_t *local;
+
#if (NGX_HTTP_CACHE)
ngx_shm_zone_t *cache;
@@ -321,6 +323,8 @@ ngx_int_t ngx_http_upstream_create(ngx_http_request_t *r);
void ngx_http_upstream_init(ngx_http_request_t *r);
ngx_http_upstream_srv_conf_t *ngx_http_upstream_add(ngx_conf_t *cf,
ngx_url_t *u, ngx_uint_t flags);
+char *ngx_http_upsteam_bind_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
ngx_int_t ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,
ngx_str_t *default_hide_headers, ngx_hash_init_t *hash);