IPv6 & IPv4 backend with proxy_bind

Ruslan Ermilov ru at nginx.com
Mon Dec 9 12:15:03 UTC 2013


On Mon, Dec 09, 2013 at 10:03:29PM +1030, SplitIce wrote:
> Im not sure that patch would suit my needs, simply because most of the time
> I am matching on the upstream address only and need it to work regardless
> of the port (i.e a regex match on just the IP component).
> 
> Perhaps your patch could be extended to support -
> 
> map $upstream_peer_addr $bind_addr {
>     127.0.0.1:8001 127.0.0.1;
>     127.0.0.2 <http://127.0.0.1:8002/> 127.0.0.1;
>     [::1]:8003     ::1;
> }
> 
> Where 127.0.0.2 would match 127.0.0.2:*
> 
> I certainly like that it doesn't require a conversion to string.

No need to modify the patch, you can already do it with map:

map $upstream_peer_addr $bind_addr {
    ~^127\.0\.0\.  127.0.0.1;
    ~^\[::1]       ::1;
}



More information about the nginx-devel mailing list