Nginx rewrite w/ multiple domains

I’ve got two domains (foo.com, bar.com) on the same nginx instance where
I want to rewrite the raw domains to a www. (i.e. foo.com rewrites to
www.foo.com and bar.com rewrites to www.bar.com)

I’ve got both sites running and the first server block redirects ok but
the second does not even though the config is identical. So foo.com
does redirect to www.foo.com but bar.com goes to foo.com instead of
www.bar.com

Can somebody help me out and see where I may have gone wrong?

I’ve attached the conf file in question.

Thank you!

Requests to foo.com and bar.com aren’t matching any of the virtual
servers so they get sent to the default one (the first one.)

Change your server_name lines to:
server_name www.foo.com foo.com;

and
server_name www.bar.com bar.com;

http://wiki.codemongers.com/NginxMailCoreModule#server_name (you
can use wildcards instead of explicitly listing the subdomains.)

On Tue, Aug 26, 2008 at 12:59 AM, Vince W.

Shawn Balestracci wrote:

Change your server_name lines to:
server_name www.foo.com foo.com;

and
server_name www.bar.com bar.com;

Thanks Shawn, that did it!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs