# HG changeset patch # User Ruslan Ermilov # Date 1386569804 -14400 # Node ID 30e806b8636af5fd3f03ec17df24801f390f7511 # Parent 1ab1cf63f885f1d2dd3c38653328cef9f3e3b784 Fixed handling of UNIX-domain sockets. When evaluating $local_port, $server_port, and $server_addr, UNIX-domain sockets were mistakenly interpreted as IPv4 sockets. diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -1095,6 +1095,12 @@ ngx_connection_local_sockaddr(ngx_connec break; #endif +#if (NGX_HAVE_UNIX_DOMAIN) + case AF_UNIX: + addr = 1; + break; +#endif + default: /* AF_INET */ sin = (struct sockaddr_in *) c->local_sockaddr; addr = sin->sin_addr.s_addr; diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -1185,6 +1185,12 @@ ngx_http_variable_remote_port(ngx_http_r break; #endif +#if (NGX_HAVE_UNIX_DOMAIN) + case AF_UNIX: + port = 0; + break; +#endif + default: /* AF_INET */ sin = (struct sockaddr_in *) r->connection->sockaddr; port = ntohs(sin->sin_port); @@ -1263,6 +1269,12 @@ ngx_http_variable_server_port(ngx_http_r break; #endif +#if (NGX_HAVE_UNIX_DOMAIN) + case AF_UNIX: + port = 0; + break; +#endif + default: /* AF_INET */ sin = (struct sockaddr_in *) r->connection->local_sockaddr; port = ntohs(sin->sin_port);