0

I heed some help figuring out why my nginx is prioritising the site this way. I have server blocks in my vhost:

server { #site 1
    listen 80;
    server_name site1.testing.domain.com$;
    root /var/www/site1/web;
    # further config
}

server { #site 2
    listen 80;
    server_name ~^(www\.)?(?<sname>.+?).testing.domain.com$;
    root /var/www/$sname/public;
    # further fonfig
}

Based on nginx documentation, it should prioritize the domain that matches fully first, but when i go on to http://site1.testing.domain.com it loads config from site 2. (If I remove the confing for dynamic subdomain, then the site 1 config works fine).

Can someone explain what am i doing wrong or why is nginx behaving this way?

3

My guess: The first variant doesn't match due to the $ at the end of the server_name, which is invalid as this isn't a regex.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.