Klaus Demo nginx / 3658a5b
fix $server_addr for wildcard listen, the has been introduced in r2513 Igor Sysoev 13 years ago
2 changed file(s) with 29 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
17901790 ngx_int_t
17911791 ngx_http_server_addr(ngx_http_request_t *r, ngx_str_t *s)
17921792 {
1793 socklen_t len;
1794 ngx_connection_t *c;
1795 u_char sa[NGX_SOCKADDRLEN];
1793 socklen_t len;
1794 ngx_uint_t addr;
1795 ngx_connection_t *c;
1796 u_char sa[NGX_SOCKADDRLEN];
1797 struct sockaddr_in *sin;
1798 #if (NGX_HAVE_INET6)
1799 ngx_uint_t i;
1800 struct sockaddr_in6 *sin6;
1801 #endif
17961802
17971803 c = r->connection;
17981804
1799 if (c->local_sockaddr == NULL) {
1805 switch (c->local_sockaddr->sa_family) {
1806
1807 #if (NGX_HAVE_INET6)
1808 case AF_INET6:
1809 sin6 = (struct sockaddr_in6 *) c->local_sockaddr;
1810
1811 for (addr = 0, i = 0; addr == 0 && i < 16; i++) {
1812 addr |= sin6->sin6_addr.s6_addr[i];
1813 }
1814
1815 break;
1816 #endif
1817
1818 default: /* AF_INET */
1819 sin = (struct sockaddr_in *) c->local_sockaddr;
1820 addr = sin->sin_addr.s_addr;
1821 break;
1822 }
1823
1824 if (addr == 0) {
18001825
18011826 len = NGX_SOCKADDRLEN;
18021827
309309 * is required to determine a server address
310310 */
311311
312 c->local_sockaddr = NULL;
313
314312 if (ngx_http_server_addr(r, NULL) != NGX_OK) {
315313 ngx_http_close_connection(c);
316314 return;