<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Why does Apache2 serve a subdomain when given an IP?</title>
	<link>http://ask.metafilter.com/116733/Why-does-Apache2-serve-a-subdomain-when-given-an-IP/</link>
	<description>Comments on Ask MetaFilter post Why does Apache2 serve a subdomain when given an IP?</description>
	<pubDate>Sat, 14 Mar 2009 02:19:01 -0800</pubDate>
	<lastBuildDate>Sat, 14 Mar 2009 02:19:01 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Why does Apache2 serve a subdomain when given an IP?</title>
		<link>http://ask.metafilter.com/116733/Why-does-Apache2-serve-a-subdomain-when-given-an-IP</link>	
		<description>I have a domain hosted on a VPS running CentOS5. Whenever I enter  http://my-vps-ip in my browser, I get redirected to http://subdomain.mysite.com. 

My limited Google-fu is no match for this particular problem, so I&apos;m hoping the folks at AskMeFi can tell me how I should setup Apache so that http://my-vps-ip goes to http://mysite.com and not the subdomain? &lt;br /&gt;&lt;br /&gt; Extracts from the httpd.conf file:&lt;br&gt;
&lt;pre&gt;&lt;br&gt;
ServerName mysite.com&lt;br&gt;
...&lt;br&gt;
UseCanonicalName Off&lt;br&gt;
&lt;/pre&gt;&lt;br&gt;
&lt;br&gt;
conf file defining the subdomain:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;br&gt;
&amp;lt;virtualhost *:80&amp;gt; &lt;br&gt;
        ServerName      subdomain.mysite.com&lt;br&gt;
        DocumentRoot    /var/www/subdomain&lt;br&gt;
        ErrorLog /var/log/httpd/subdomain_mysite_com-error.log&lt;br&gt;
        CustomLog /var/log/httpd/subdomain_mysite-access.log combined&lt;br&gt;
    &amp;lt;directory&amp;gt; &lt;br&gt;
        Options Indexes FollowSymLinks&lt;br&gt;
        AllowOverride AuthConfig FileInfo Indexes Limit&lt;br&gt;
       Order allow,deny&lt;br&gt;
       Allow from all&lt;br&gt;
     &amp;lt;/directory&amp;gt; &lt;br&gt;
&amp;lt; /virtualhost&amp;gt; &lt;br&gt;
&lt;/pre&gt;&lt;br&gt;
&lt;br&gt;
Also, FWIW - currently the rDNS lookup on my VPS IP goes to ns1.mysite.com.&lt;br&gt;
&lt;br&gt;
Many thanks!</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2009:site.116733</guid>
		<pubDate>Sat, 14 Mar 2009 00:41:20 -0800</pubDate>
		<dc:creator>your mildly obsessive average geek</dc:creator>
		
			<category>apache</category>
		
			<category>vps</category>
		
			<category>centos</category>
		
			<category>subdomain</category>
		
			<category>resolved</category>
		
	</item> <item>
		<title>By: hades</title>
		<link>http://ask.metafilter.com/116733/Why-does-Apache2-serve-a-subdomain-when-given-an-IP#1673447</link>	
		<description>If you have a name-based virtualhost listening on all IPs, as you do with &amp;lt;virtualhost *:80&amp;gt;, the first virtualhost stanza will be the default, handling any queries which don&apos;t match ServerNames from other virtualhost stanzas. Which is to say that what you think is your main server configuration in httpd.conf isn&apos;t getting used, except to set up default values, some of which are being overridden by the corresponding values in virtualhost stanzas.&lt;br&gt;
&lt;br&gt;
If you want mysite.com to be the default, you&apos;ll probably have to set up a virtualhost stanza for it, too, and make sure it appears before the subdomain.mysite.com virtualhost stanza. If you&apos;re doing this with files in conf.d, numbering them is one way to accomplish that: 00_mysite.com.conf, 10_subdomain.mysite.com.conf, etc.&lt;br&gt;
&lt;br&gt;
See the &quot;Main host goes away&quot; section at &lt;a href=&quot;http://httpd.apache.org/docs/2.2/vhosts/name-based.html&quot;&gt;http://httpd.apache.org/docs/2.2/vhosts/name-based.html&lt;/a&gt; for more.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.116733-1673447</guid>
		<pubDate>Sat, 14 Mar 2009 02:19:01 -0800</pubDate>
		<dc:creator>hades</dc:creator>
	</item><item>
		<title>By: your mildly obsessive average geek</title>
		<link>http://ask.metafilter.com/116733/Why-does-Apache2-serve-a-subdomain-when-given-an-IP#1673453</link>	
		<description>hades - I already have the following virtual host entries setup at the end of my primary httpd.conf:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;br&gt;
#Virtual Host for main server&lt;br&gt;
&amp;lt;VirtualHost *:80&amp;gt;&lt;br&gt;
ServerName www.mysite.com&lt;br&gt;
ServerAdmin webmaster@mysite.com&lt;br&gt;
DocumentRoot /var/www/html&lt;br&gt;
ErrorLog /var/log/httpd/mysite_com-error.log&lt;br&gt;
CustomLog /var/log/httpd/mysite-access.log combined&lt;br&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br&gt;
&lt;br&gt;
#Virtual Host to handle non www requests&lt;br&gt;
&amp;lt;VirtualHost *:80&amp;gt;&lt;br&gt;
ServerName mysite.com&lt;br&gt;
ServerAdmin webmaster@mysite.com&lt;br&gt;
DocumentRoot /var/www/html&lt;br&gt;
ErrorLog /var/log/httpd/mysite_com-error.log&lt;br&gt;
CustomLog /var/log/httpd/mysite-access.log combined&lt;br&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br&gt;
&lt;/pre&gt;&lt;br&gt;
&lt;br&gt;
Am I correct in understanding that the entries in my virtual hosts conf file is overriding these entries? So if I were to move these to the top of my virtual hosts conf file - Apache should stop serving subdomain.mysite.com for the VPS IP?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.116733-1673453</guid>
		<pubDate>Sat, 14 Mar 2009 02:42:09 -0800</pubDate>
		<dc:creator>your mildly obsessive average geek</dc:creator>
	</item><item>
		<title>By: ArkhanJG</title>
		<link>http://ask.metafilter.com/116733/Why-does-Apache2-serve-a-subdomain-when-given-an-IP#1673686</link>	
		<description>Yes, that&apos;s the normal setup.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.116733-1673686</guid>
		<pubDate>Sat, 14 Mar 2009 09:39:24 -0800</pubDate>
		<dc:creator>ArkhanJG</dc:creator>
	</item><item>
		<title>By: rhizome</title>
		<link>http://ask.metafilter.com/116733/Why-does-Apache2-serve-a-subdomain-when-given-an-IP#1673725</link>	
		<description>Also, you can &lt;a href=&quot;http://httpd.apache.org/docs/2.2/vhosts/examples.html#default&quot;&gt;use _default_&lt;/a&gt; so that you don&apos;t have to pay attention to the order of your vhosts.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.116733-1673725</guid>
		<pubDate>Sat, 14 Mar 2009 10:25:53 -0800</pubDate>
		<dc:creator>rhizome</dc:creator>
	</item><item>
		<title>By: hades</title>
		<link>http://ask.metafilter.com/116733/Why-does-Apache2-serve-a-subdomain-when-given-an-IP#1673740</link>	
		<description>There&apos;s probably a line in the middle of your main httpd.conf which reads:&lt;pre&gt;Include conf.d/*.conf&lt;/pre&gt;&lt;br&gt;
If your subdomain is being configured from a file in conf.d, it&apos;s actually coming before those stanzas at the end of httpd.conf, because of the include statement&apos;s position. Like rhizome said, you can use _default_, or you can put your main server configs in conf.d files lexically earlier than your subdomain config files.&lt;br&gt;
&lt;br&gt;
Also, you don&apos;t need two stanzas for www.mysite.com and mysite.com; you can put&lt;pre&gt;ServerAlias mysite.com&lt;/pre&gt;in the first stanza and get rid of the second.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.116733-1673740</guid>
		<pubDate>Sat, 14 Mar 2009 10:42:20 -0800</pubDate>
		<dc:creator>hades</dc:creator>
	</item><item>
		<title>By: your mildly obsessive average geek</title>
		<link>http://ask.metafilter.com/116733/Why-does-Apache2-serve-a-subdomain-when-given-an-IP#1674355</link>	
		<description>I tried adding the _default_ option to the Virtual Host entry in the httpd.conf but I think the &quot;Include conf.d/*.conf line&quot; is still taking precedence.&lt;br&gt;
&lt;br&gt;
In any case, I moved the Virtual Host entry for mysite.com to the same conf file as the sub-domain and added the _default_ option. After that, it started working!&lt;br&gt;
&lt;br&gt;
hades - thanks for the tip on the ServerAlias.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2009:site.116733-1674355</guid>
		<pubDate>Sun, 15 Mar 2009 02:51:38 -0800</pubDate>
		<dc:creator>your mildly obsessive average geek</dc:creator>
	</item>
	</channel>
</rss>
