For development, I would like to serve several projects in different local domains, all on port 80. In my hosts file, I direct local.example.com to localhost, the same goes for local.example2.com.
Now I'm trying to convince nginx to serve example resources for one url, and example2 resources for another.
I read the nginx documentation and this blog post . But I think I'm missing something.
I added to my nginx.conf:
include /Users/iwein/Sites/conf/*.conf;
Then on sites I add a configuration like example.conf :
server { listen 80; server_name local.example.com; β¦
and example2.conf :
server { listen 80; server_name local.example2.com; β¦
Now itβs strange that nginx loads the alphabetically first config, but at the second URL it also serves resources from the first server definition. Nginx seems to completely ignore server_name. How do I configure this use case?
UPDATE:
It seems that if you use only one separator per domain name (e.g. example1.local), it works fine. I didn't chase it anymore because I have better things to do, but it's weird.
nginx
iwein
source share