title: Nginx map regex with multiple variables to one variable
body: <p>Map variables to $clientIP with regex.</p>
  
  <p>Webserver behind multiple CDN, The custom header with the client's real ip varies. So I came out with the follow expression.</p>
  
  <pre><code>#here I use @ as seperator
  map "$http_cf_connecting_ip@$http_cdn_src_ip@$http_src_ip@$http_client_ip" $clientIP {
  
            "~[^-]+@-@-@-$"       $http_cf_connecting_ip;                 
            "~^-@[^-]+@-@-$"      $http_cdn_src_ip;        
            "~^-@-@[^-]+@-$"      $http_src_ip;             
            "~^-@-@-@[^-]+$"      $http_client_ip;
            "~^-@-@-@-$"          $remote_addr;
            default               $remote_addr;
  }
  </code></pre>
  
  <p>I use postman to send custom http headers. But seems map will always go to default.</p>