Subdomain redirect help

Floren Munteanu nginx at yqed.com
Sat May 9 09:10:57 MSD 2009


Hi all,

I have 2 servers, one with development stuff and one with live data. I
also have 4 static IPs available. Right now, one of them is used to
point domain.com to the proper server. My goal is to redirect
www.domain.com to 192.168.1.3 and dev.domain.com to 192.168.1.4. I have
www.domain.com forwarded to 192.1681.3, it is working perfect. If I type
domain.com, it will bring me to www.domain.com, I can view the site.

What configuration should I use in order to have the dev.domain.com
forwarded to 192.168.1.4?
I've tried this, it does not work:
server {
	listen				192.168.1.4:80;
	server_name				dev.domain.com;
	root					/var/www/dev;
	... more config params here ...
}

server {
	listen				192.168.1.3:80;
	server_name				domain.com;
	rewrite		^(.*)$	$scheme://www.domain.com$1 permanent;
}

server {
	listen				192.168.1.3:80;
	server_name				www.domain.com;
	root					/var/www/html;
	... more config params here ...
}

I did a test. I installed nginx on 192.168.1.4 also and ran it directly:
http://192.168.1.4/ everything was OK.

I don't mind running nginx on both servers. All I want is to have
dev.domain.com available to a small group of people. The 192.168.1.4
server is the place where all configuration tests and other programming
tasks are getting completed, so it does not affect the live server
performance nor it interacts in any way with it, beside the subdomain
name.

Thanks a lot for you help.

Floren







More information about the nginx mailing list