# Mapping a User Agent to an IP address:

**URL:** <https://www.ruby-forum.com/t/mapping-a-user-agent-to-an-ip-address/217031>\
**Category:** NGINX\
**Created:** [February 20, 2012, 8:29am UTC](https://www.ruby-forum.com/t/mapping-a-user-agent-to-an-ip-address/217031 "2012-02-20T08:29:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 20, 2012, 8:29am UTC](https://www.ruby-forum.com/t/mapping-a-user-agent-to-an-ip-address/217031/1 "2012-02-20T08:29:14Z")

</div>

Hey guys,

I’m running NGINX as a front for my apache servers and I’m having  
issues where mappings within the config on occasion aren’t being set.  
For instance with the following config:

func $my\_ip\_match{  
default 0;  
1.1.1.1/32 1;  
1.1.1.2/32 1;  
1.1.1.3/32 1;  
1.1.1.4/32 1;  
}

#map the matches  
map $name $match\_value {  
default 0;  
~\*name\_1 $my\_ip\_match;  
~\*name\_2 $my\_ip\_match;  
~\*name\_3 $my\_ip\_match;  
~\*name\_4 $my\_ip\_match;  
}

$my\_ip\_match will be set if the given IP/subnet is matched, but the  
subsequent mapping is randomly executed. I haven’t been able to come  
up with any reason why it ocassionally doesn’t map. Is there any  
reason for this?

Thanks in advance!  
/Engin
