Conflicting server name - i don't understand
Jim Ohlstein
jim at ohlste.in
Thu Sep 3 02:06:34 MSD 2009
Nuno Magalhães wrote:
>> This does not generate any errors.
>>
> Glad to hear it.
>
>
>
>> (Yes, I also don't like the www prefix.)
>>
> Do you have a specific reason for using two server{ } for the same
> domain? Other than
>
>
>> This also is *exactly* how Igor suggested that I do it.
>>
>
>
Yes. *If* I recall correctly, it came about when I posted a site
configuration for another reason. At the time I was using an "if" clause
to rewrite "www.domain.com" to "domain.com".
It probably went something like:
<http://wiki.nginx.org/NginxHttpRewriteModule#if>if ($host ~* www\.(.*)) {
<http://wiki.nginx.org/NginxHttpRewriteModule#set>set $host_without_www $1;
rewrite <http://wiki.nginx.org/NginxHttpRewriteModule#rewrite> ^(.*)$ <http://wiki.nginx.org/NginxHttpCoreModule#http> http://$host_without_www$1 permanent;
}
Again, *if* I recall correctly, Igor suggested that using a separate
server entry with a rewrite and eliminating the "if" clause would be far
more efficient. It's been far too many years than I care to admit (but
perhaps near if not greater than the median age on this mailing list)
since I mucked around in C so who am I to argue?
>
>> But even if I didn't do it that way I would still use separate servers for
>> 80 and 443 for the same domain.
>>
>
> Does the listen directive accept multiple values? Or does the server
> accept multiple listen directives?
I don't know. Never tried.
> The latter seems to be true
> according to the wiki, so why the separation?
>
>
Cleaner. Easier to edit and follow. Easier to cut and paste when
creating new domains. Probably more style than substance though. :)
Jim
More information about the nginx
mailing list