1

My main site is accessed by the address www.example.com, so should by my nginx virtual host file named as www.example.com and not example.com to avoid searches of the server_name variable www in others blocks of virtual host files?

The same thing apply to apache?, www.example.com.conf and not example.com.conf

This make sense or both do not count www. in file names by default?

  • it's absolutely irrelevant how the file is called. That's just for you, so you know what file contains what. – Gerald Schneider Dec 6 '17 at 7:15
1

... to avoid searches of the server_name variable www in others blocks of virtual host files

The name of the file is (almost) inconsequential to the httpd server. When the system starts the contents of the conf files are read into and cached in memory. Any searches are performed against this cache at the speed of memory.

... so should by my nginx virtual host file named as www.example.com and not example.com

Use whichever makes most sense to you. Personally I use the primary name to name the conf files.

0

Configuration files are loaded in filename order and parsed internally so after the load at startup are accessed through a hash, so it doesn't really make a lot of difference in my experience. I would tend to keep VirtualHosts in a domain together so would name the virtual hosts for the domain.

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.