Suppose I have these paths:
/
/something # this path is variable (any characters except /)
/api/v1/something
What is the best nginx config to capture this requirement? The following is not working for m:
server {
    listen 8080;
    location ~^/(?:.*)$ {
        ...
    }
    location / {
        ...
    }
    location /api/v1/something {
        ...
    }
}
				
                        
Your regular expression matches everything which means it always wins! See the documentation to understand how Nginx chooses which
locationblock to process a request.You do not need to use a regular expression
location.First define
locationblocks for the single URIs using the=operator:Then use the default
locationto catch anything else:The above
locationblocks can appear in any order. Only regular expressions are sensitive to evaluation order.