This regex sets different parts of the url host in variables :
- $domain
- $namespace
- $feature
- $isAPI
- $noMatch
In the host name we want to be able to determine the following:
- Domain: if not on a handled DNS domains, an error 503 'no Service' is returned
- Subdomain: The subdomain contains parts that will redirect the request upstream or send errors, considering the following.
- empty subdomain redirects to wwwnamespace with code 301
- Feature: when the first member of the subdomain is prefixed by feature-, redirects to the proper 'feature' upstream built serverfeature-*.app:8080
- API: when the subdomain contains apias last element, it is redirected to the API node server (eventually the one of a dedicated feature)[feature-*|default].api:8081
- Namespace: any single string subdomain different from the 2 above, redirected upstream to the default staging server default.app:8080.
- noMatch: all uncatched subdomain pattern results in an error 503 no Service
 
If no upstream server is found, the nginx proxy will return an error 502 maintenance