diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-03-18 12:23:57 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-03-18 12:23:57 +0000 |
commit | 3658a5bdc655d27d5457c3a1de20b02ac0cddf46 (patch) | |
tree | 9d840e1bacf1a8b4d610e1deb7397f3e28d4b6eb /src/http/ngx_http_core_module.c | |
parent | f76a6c2244dc20f7cfe01bb3261341436f0ac598 (diff) | |
download | nginx-3658a5bdc655d27d5457c3a1de20b02ac0cddf46.tar.gz nginx-3658a5bdc655d27d5457c3a1de20b02ac0cddf46.zip |
fix $server_addr for wildcard listen, the has been introduced in r2513
Diffstat (limited to 'src/http/ngx_http_core_module.c')
-rw-r--r-- | src/http/ngx_http_core_module.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 66b3cee16..43d464418 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -1791,13 +1791,38 @@ ngx_http_auth_basic_user(ngx_http_request_t *r) ngx_int_t ngx_http_server_addr(ngx_http_request_t *r, ngx_str_t *s) { - socklen_t len; - ngx_connection_t *c; - u_char sa[NGX_SOCKADDRLEN]; + socklen_t len; + ngx_uint_t addr; + ngx_connection_t *c; + u_char sa[NGX_SOCKADDRLEN]; + struct sockaddr_in *sin; +#if (NGX_HAVE_INET6) + ngx_uint_t i; + struct sockaddr_in6 *sin6; +#endif c = r->connection; - if (c->local_sockaddr == NULL) { + switch (c->local_sockaddr->sa_family) { + +#if (NGX_HAVE_INET6) + case AF_INET6: + sin6 = (struct sockaddr_in6 *) c->local_sockaddr; + + for (addr = 0, i = 0; addr == 0 && i < 16; i++) { + addr |= sin6->sin6_addr.s6_addr[i]; + } + + break; +#endif + + default: /* AF_INET */ + sin = (struct sockaddr_in *) c->local_sockaddr; + addr = sin->sin_addr.s_addr; + break; + } + + if (addr == 0) { len = NGX_SOCKADDRLEN; |