Maybe not exactly what your looking for but should give enough to rewrite this for what you want with map. https://gist.github.com/anonymous/68caceb6c935e7120a60 Posted at Nginx Forum: http://forum.nginx.org/read.php?2,251908,251917#msg-251917