In Apache, if 1) I have multiple virtual hosts listening to one port and 2) if no requests match any of the virtual host, then the first virtual host will be the one that will answer the request. For example, given I have this config:
<VirtualHost *:8080> ServerName www.fallbacksite.com:8080 ServerAlias *.fallbacksite.com # ... </VirtualHost> <VirtualHost *:8080> ServerName www.specific-site.com:8080 ServerAlias *.specific-site.com # ... </VirtualHost>
- When someone specific-site.com:8080, then the second virtual host will be answer the request (no surprise here)
- When someone visits fallbacksite.com:8080, then the first virtual host will answer the request (no surprise here)
- When someone visits hellohowareyou.com:8080 (and hellohowareyou.com points to the server), then the first virtual host will answer the request
It's the last scenario I'm trying to implement with nginx, but could not see anything in the nginx.org site talking about this. I tried over-eager wildcards but it complains that it is not valid.
How would you do the above confiuration in nginx? Thanks in advance!