Do you put all your virtual host info in nginx.conf?

Hello,

Do you put all your virtual host info in nginx.conf? Since I got a lot
of
virtual hosts, if I put all of them into nginx.conf, I found it’s rather
big. Just want to know what’s the best practice to handle many virtual
hosts. Thanks.

Max

The best way is to include separate config files using the include
directive:
http://wiki.codemongers.com/NginxHttpMainModule#include

Nick

I also put all virtual host conf into nginx, separate them on
virtual.conf.

I just wonder it will be more difficult if I want to change things for
multiple sites (multiple virtual conf files). For example, if I want to
change ip from 111.111.111.111 to 222.222.222.222, I just open the
nginx.conf and so a search and replace, it will be replaced them all at
once. If it’s in multiple virtual file, I need to open those doamins
which
are using 111.111.111.111 and chagne them manually.

Doesn’t seem any harder to me.

sed -i.bak ‘s/111.111.111.111/222.222.222.222/g’ *.conf

-dg

On Wed, 2009-02-18 at 15:56 +0800, Max wrote:

I just wonder it will be more difficult if I want to change things
for multiple sites (multiple virtual conf files). For example, if I
want to change ip from 111.111.111.111 to 222.222.222.222, I just open
the nginx.conf and so a search and replace, it will be replaced them
all at once. If it’s in multiple virtual file, I need to open those
doamins which are using 111.111.111.111 and chagne them manually.

Use the “map” directive to map domain names to IP addresses. That is
stored in its own file, mappings.conf. Then each domain gets its own
conf file that is included.

http://wiki.codemongers.com/NginxHttpMapModule

This way, to change an IP address, you only need to edit the
mappings.conf file.

Cliff

A records usually configured in DNS zone. Do you use bind? Simply put
listen
PORT; without IP.

Yes, that’s the best way to configure it.

Yes, I am currently using catchall as well. But all virtaul host hogs
going
to one big log file. I am using 0.633. I can’t use something like
path/$host.access.log main; to have seperate log files.

I use a “catchall” setup.

Joe a écrit :