I have two different server_name in nginx.conf file:
First one as:
server_name ~^(?<subdomain>.+)\.nithinveer\.com$;
location /
{
proxy_pass http://192.168.6.190/Profiles/$subdomain/default.aspx$request_uri/;
access_log /var/log/nginx/true.log;
}
Another one as
server_name ~^(?<subdomain>.+)\.nithinveer\.com\.(?<extension>)$;
location /extension
{
proxy_pass http://192.168.6.190;
access_log /var/log/nginx/false.log;
}
Now the thing is I want to use both the server_name based on the in the server_name. If there is no extension with the server_name it should go to first location. If there is an extension, it should go to second location.
But while running the nginx, it is not moving into the second server_name
Can anyone please find some solution for this...?
I thought a solution as(may be wrong).
server_name ~^(?<subdomain>.+)\.nithinveer\.com\.(?<extension>.+)$;
if($<extension> == NULL)
{
location /
{
proxy_pass http://192.168.6.190/Profiles/$subdomain/default.aspx$request_uri/;
access_log /var/log/nginx/true.log;
}
}
else
{ location /
{
proxy_pass http://192.168.6.190;
access_log /var/log/nginx/false.log;
}
But the syntax with the if statement throws an error.