mirror of
https://github.com/nginx/nginx.git
synced 2025-08-01 02:56:15 +08:00
fix $server_addr for wildcard listen, the has been introduced in r2513
This commit is contained in:
parent
f76a6c2244
commit
3658a5bdc6
@ -1791,13 +1791,38 @@ ngx_http_auth_basic_user(ngx_http_request_t *r)
|
|||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_http_server_addr(ngx_http_request_t *r, ngx_str_t *s)
|
ngx_http_server_addr(ngx_http_request_t *r, ngx_str_t *s)
|
||||||
{
|
{
|
||||||
socklen_t len;
|
socklen_t len;
|
||||||
ngx_connection_t *c;
|
ngx_uint_t addr;
|
||||||
u_char sa[NGX_SOCKADDRLEN];
|
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;
|
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;
|
len = NGX_SOCKADDRLEN;
|
||||||
|
|
||||||
|
@ -310,8 +310,6 @@ ngx_http_init_request(ngx_event_t *rev)
|
|||||||
* is required to determine a server address
|
* is required to determine a server address
|
||||||
*/
|
*/
|
||||||
|
|
||||||
c->local_sockaddr = NULL;
|
|
||||||
|
|
||||||
if (ngx_http_server_addr(r, NULL) != NGX_OK) {
|
if (ngx_http_server_addr(r, NULL) != NGX_OK) {
|
||||||
ngx_http_close_connection(c);
|
ngx_http_close_connection(c);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user