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?

2 Answers2

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.

user9517
  • 114,104
  • 20
  • 206
  • 289
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.

Simon Greenwood
  • 1,343
  • 9
  • 12