I don’t want to add any versioning logic to the API.
If I use Wildcard Sub-domains and regex in nginx.conf to determine subdomain part, I can route the request to specific directory. Here is the config:
server {
listen 80;
server_name .api.domain.com;
set $version $host;
if ($version ~ "^(.+).api.domain.com") {
set $version $1;
}
access_log /var/log/nginx/$version-access.log;
error_log /var/log/nginx/$version-error.log info;
location / {
root /opt/webapps/app_$version/www/;
index index.php;
}
}
Question: Is there any disadvantage of such technique?
I found better way – named captures in server_name:
This is method is better because: