Add regexp for replacement to Location section.

In case of '.' in location path parser is not working properly
to configure nginx. So nginx fails with error.

Fixes-bug: PROD-37013
Change-Id: I0d2e74977199e5bc7c826a40b1603000919dde66
diff --git a/nginx/files/_limit.conf b/nginx/files/_limit.conf
index b60406b..7d1879e 100644
--- a/nginx/files/_limit.conf
+++ b/nginx/files/_limit.conf
@@ -38,28 +38,28 @@
       {%- if location.get('limit', {}).get('enabled', False) and location.limit.methods is defined %}
         {%- if location.limit.methods.ip is defined and location.limit.methods.get('ip').get('enabled',False) %}
       # Create whitelist for ip addresses
-geo $ip_{{ site_name }}_{{ path|replace('/','_') }} {
+geo $ip_{{ site_name }}_{{ path|regex_replace("[^A-Za-z0-9]", "") }} {
     default "enforce";
   {%- for ip in location.limit.methods.ip.get('ip_whitelist', []) %}
     {{ ip }} "whitelist";
   {%- endfor %}
 }
       # First, map all whitelisted IP's to the request query
-map $ip_{{ site_name }}_{{ path|replace('/','_') }} $limit_{{ site_name }}_{{ path|replace('/','_') }} {
+map $ip_{{ site_name }}_{{ path|regex_replace("[^A-Za-z0-9]", "") }} $limit_{{ site_name }}_{{ path|regex_replace("[^A-Za-z0-9]", "") }} {
     default {{ location.limit.methods.ip.get('query', '$binary_remote_addr') }};
     "whitelist" "";
 }
 
-limit_req_zone $limit_{{ site_name }}_{{ path|replace('/','_') }} zone=ip_{{ site_name }}_{{ path|replace('/','_') }}:{{ location.limit.methods.ip.get('size', '10m') }} rate={{ location.limit.methods.ip.get('rate','10r/s') }};
+limit_req_zone $limit_{{ site_name }}_{{ path|regex_replace("[^A-Za-z0-9]", "") }} zone=ip_{{ site_name }}_{{ path|regex_replace("[^A-Za-z0-9]", "") }}:{{ location.limit.methods.ip.get('size', '10m') }} rate={{ location.limit.methods.ip.get('rate','10r/s') }};
       {%- endif %}
 
 {%- for method, method_data in location.limit.methods.items() %}
 {%- if method != 'ip' %}
-map $request_method $limit_{{ method }}_{{ site_name }}_{{ path|replace('/','_') }} {
+map $request_method $limit_{{ method }}_{{ site_name }}_{{ path|regex_replace("[^A-Za-z0-9]", "") }} {
     default "";
     {{ method|upper }} "limit_{{ method }}";
 }
-limit_req_zone $limit_{{ method }}_{{ site_name }}_{{ path|replace('/','_') }} zone={{ method }}_{{ site_name }}_{{ path|replace('/','_') }}:{{ location.limit.methods.get(method,{}).get('size', '10m') }} rate={{ location.limit.methods.get(method,{}).get('rate','10r/s') }};
+limit_req_zone $limit_{{ method }}_{{ site_name }}_{{ path|regex_replace("[^A-Za-z0-9]", "") }} zone={{ method }}_{{ site_name }}_{{ path|regex_replace("[^A-Za-z0-9]", "") }}:{{ location.limit.methods.get(method,{}).get('size', '10m') }} rate={{ location.limit.methods.get(method,{}).get('rate','10r/s') }};
 {%- endif %}
 {%- endfor %}
       {%- endif %}
diff --git a/nginx/files/proxy.conf b/nginx/files/proxy.conf
index 7aac4a4..ffa8d2c 100644
--- a/nginx/files/proxy.conf
+++ b/nginx/files/proxy.conf
@@ -149,7 +149,7 @@
       {%- if location.limit is defined  and location.limit.methods is defined %}
         {%- for method, method_data in location.limit.methods.items() %}
           {%- if method_data.get('enabled', False) %}
-      limit_req zone={{ method }}_{{ site_name+'_'+path|replace('/','_') }}{% if method_data.get('burst', False) %} burst={{ method_data.burst }}{% endif %}{% if method_data.get('nodelay', False) %} nodelay{% endif %};
+      limit_req zone={{ method }}_{{ site_name+'_'+path|regex_replace("[^A-Za-z0-9]", "") }}{% if method_data.get('burst', False) %} burst={{ method_data.burst }}{% endif %}{% if method_data.get('nodelay', False) %} nodelay{% endif %};
           {%- endif %}
         {%- endfor %}