Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Fri Apr 15, 2011 5:55 am 
Offline
Senior Newbie

Joined: Wed Feb 16, 2011 7:04 am
Posts: 8
Location: Southampton
Hi All,

I have the following config for a site. I can access my site at http://www.carswellgould.co.uk but not at http://carswellgould.co.uk. (the page there is from the 000-default site. Any ideas what could be causing this?

When I disable the default site, I can access the site correctly, however, cruisedover.com, which has no site configured, points to one of my other sites on the server. It's just not making sense!

Other things to note: I recently changed the reverse dns to carswellgould.co.uk
pinging carswellgould.co.uk from the server returns the correct public IP.

Code:
<VirtualHost *:80>
   ServerAdmin rob@carswellgould.co.uk
 
   ServerName carswellgould.co.uk
   ServerAlias carswellgould.com *.carswellgould.co.uk www.carswellgould.com
   
   DocumentRoot /home/cglive/cms/public_html/
   <Directory />
      Options FollowSymLinks
      AllowOverride None
   </Directory>
   <Directory /home/cglive/cms/public_html/>
      Options Indexes FollowSymLinks
      AllowOverride All
      Order allow,deny
      allow from all
      
      
      # ----------------------------------------------------------------------
      # Better website experience for IE users
      # ----------------------------------------------------------------------

      # Force the latest IE version, in various cases when it may fall back to IE7 mode
      #  github.com/rails/rails/commit/123eb25#commitcomment-118920
      # Use ChromeFrame if it's installed for a better experience for the poor IE folk

      <IfModule mod_setenvif.c>
        <IfModule mod_headers.c>
         BrowserMatch MSIE ie
         Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
        </IfModule>
      </IfModule>

      <IfModule mod_headers.c>
      # Because X-UA-Compatible isn't sent to non-IE (to save header bytes),
      #   We need to inform proxies that content changes based on UA
        Header append Vary User-Agent
      # Cache control is set only if mod_headers is enabled, so that's unncessary to declare
      </IfModule>



      # ----------------------------------------------------------------------
      # Proper MIME type for all files
      # ----------------------------------------------------------------------

      # audio
      AddType audio/ogg                      oga ogg

      # video
      AddType video/ogg                      ogv
      AddType video/mp4                      mp4
      AddType video/webm                     webm

      # Proper svg serving. Required for svg webfonts on iPad
      #   twitter.com/FontSquirrel/status/14855840545
      AddType     image/svg+xml              svg svgz
      AddEncoding gzip                       svgz
                                           
      # webfonts                             
      AddType application/vnd.ms-fontobject  eot
      AddType font/truetype                  ttf
      AddType font/opentype                  otf
      AddType application/x-font-woff        woff

      # assorted types                                     
      AddType image/x-icon                   ico
      AddType image/webp                     webp
      AddType text/cache-manifest            appcache manifest
      AddType text/x-component               htc
      AddType application/x-chrome-extension crx
      AddType application/x-xpinstall        xpi
      AddType application/octet-stream       safariextz

      # ----------------------------------------------------------------------
      # gzip compression
      # ----------------------------------------------------------------------

      <IfModule mod_deflate.c>


      # force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
      <IfModule mod_setenvif.c>
        <IfModule mod_headers.c>
         SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s,?\s(gzip|deflate)?|X{4,13}|~{4,13}|-{4,13})$ HAVE_Accept-Encoding
         RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
        </IfModule>
      </IfModule>
      # html, txt, css, js, json, xml, htc:
      <IfModule filter_module>
        FilterDeclare   COMPRESS
        FilterProvider  COMPRESS  DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
        FilterProvider  COMPRESS  DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
        FilterChain     COMPRESS
        FilterProtocol  COMPRESS  change=yes;byteranges=no
      </IfModule>

      <IfModule !mod_filter.c>
        # Legacy versions of Apache
        AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
        AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
        AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
      </IfModule>

      # webfonts and svg:
        <FilesMatch "\.(ttf|otf|eot|svg)$" >
         SetOutputFilter DEFLATE
        </FilesMatch>
      </IfModule>

      # ----------------------------------------------------------------------
      # Expires headers (for better cache control)
      # ----------------------------------------------------------------------

      # these are pretty far-future expires headers
      # they assume you control versioning with cachebusting query params like
      #   <script src="application.js?20100608">
      # additionally, consider that outdated proxies may miscache
      #   www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/

      # if you don't use filenames to version, lower the css and js to something like
      #   "access plus 1 week" or so

      <IfModule mod_expires.c>
        ExpiresActive on

      # Perhaps better to whitelist expires rules? Perhaps.
        ExpiresDefault                          "access plus 1 month"

      # cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
        ExpiresByType text/cache-manifest       "access plus 0 seconds"

      # your document html
        ExpiresByType text/html                 "access plus 0 seconds"
       
      # data
        ExpiresByType text/xml                  "access plus 0 seconds"
        ExpiresByType application/xml           "access plus 0 seconds"
        ExpiresByType application/json          "access plus 0 seconds"

      # rss feed
        ExpiresByType application/rss+xml       "access plus 1 hour"

      # favicon (cannot be renamed)
        ExpiresByType image/x-icon              "access plus 1 week"

      # media: images, video, audio
        ExpiresByType image/gif                 "access plus 1 month"
        ExpiresByType image/png                 "access plus 1 month"
        ExpiresByType image/jpg                 "access plus 1 month"
        ExpiresByType image/jpeg                "access plus 1 month"
        ExpiresByType video/ogg                 "access plus 1 month"
        ExpiresByType audio/ogg                 "access plus 1 month"
        ExpiresByType video/mp4                 "access plus 1 month"
        ExpiresByType video/webm                "access plus 1 month"
       
      # htc files  (css3pie)
        ExpiresByType text/x-component          "access plus 1 month"
       
      # webfonts
        ExpiresByType font/truetype             "access plus 1 month"
        ExpiresByType font/opentype             "access plus 1 month"
        ExpiresByType application/x-font-woff   "access plus 1 month"
        ExpiresByType image/svg+xml             "access plus 1 month"
        ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
      
      # css and javascript
        ExpiresByType text/css                  "access plus 2 months"
        ExpiresByType application/javascript    "access plus 2 months"
        ExpiresByType text/javascript           "access plus 2 months"
       
        <IfModule mod_headers.c>
         Header append Cache-Control "public"
        </IfModule>
       
      </IfModule>
      FileETag None

      # ----------------------------------------------------------------------
      # Start rewrite engine
      # ----------------------------------------------------------------------

      # Turning on the rewrite engine is necessary for the following rules and features.

      <IfModule mod_rewrite.c>
        RewriteEngine On
      </IfModule>

      <IfModule mod_rewrite.c>
        RewriteCond %{HTTPS} !=on
        RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
        RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
      </IfModule>

      <IfModule mod_rewrite.c>
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
        RewriteRule ^(.*)$ /$1/ [R=301,L]
      </IfModule>

      Options -MultiViews
      AddCharset utf-8 .html .css .js .xml .json .rss

      # Block access to "hidden" directories whose names begin with a period. This
      # includes directories used by version control systems such as Subversion or Git.
      <IfModule mod_rewrite.c>
        RewriteRule "(^|/)\." - [F]
      </IfModule>
   </Directory>

   ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
   <Directory "/usr/lib/cgi-bin">
      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all
   </Directory>

   ErrorLog ${APACHE_LOG_DIR}/error.log

   # Possible values include: debug, info, notice, warn, error, crit,
   # alert, emerg.
   LogLevel warn

   CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>


Top
   
 Post subject:
PostPosted: Fri Apr 15, 2011 6:22 am 
Offline
Senior Newbie

Joined: Fri Apr 15, 2011 6:18 am
Posts: 8
Let me guess, your server hostname is "carswellgould.co.uk", right?
In this is the case, your default VirtualHost will match "carswellgould.co.uk" before any other virtual hosts.
cruisedover.com will probably be pointing to some random host on the machine chosen by some Apache voodoo, since no other VHosts match.


Top
   
 Post subject:
PostPosted: Fri Apr 15, 2011 6:37 am 
Offline
Senior Newbie

Joined: Wed Feb 16, 2011 7:04 am
Posts: 8
Location: Southampton
Theres no names specified in the default site. I think i know why cruisdover isnt working. It picks the first in the vhost list. I think ill disable thr default one for the time being.


Top
   
 Post subject:
PostPosted: Fri Apr 15, 2011 6:38 am 
Offline
Senior Newbie

Joined: Fri Apr 15, 2011 6:18 am
Posts: 8
Unforeseen wrote:
Theres no names specified in the default site.

Yes, there is no name specified in the default, but if your server hostname is "carswellgould.co.uk" (check by using 'hostname -f' on the command line), then this will be the name used for the default vhost.


Top
   
 Post subject:
PostPosted: Fri Apr 15, 2011 7:04 am 
Offline
Senior Newbie

Joined: Wed Feb 16, 2011 7:04 am
Posts: 8
Location: Southampton
Thank you for your help :)

I thought it may have something to do with that. However, hostname -f returns:

Code:
root@li300-186:~# hostname -f
li300-186.members.linode.com


Top
   
 Post subject:
PostPosted: Fri Apr 15, 2011 7:37 am 
Offline
Senior Newbie

Joined: Wed Feb 16, 2011 7:04 am
Posts: 8
Location: Southampton
I was hoping to have the default as a 'catch all others' account.

For the moment I've disabled this and manually added cruisedover to a different site.

Bit of a shame, really.


Top
   
 Post subject:
PostPosted: Fri Apr 15, 2011 10:24 am 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
A handy command to see what Apache thinks about your VirtualHost configuration is 'apache2ctl -S' ... note that it groups virtual hosts by NameVirtualHost, and it can get somewhat weird if you have wildcards and explicit IPs in different places (that is, <VirtualHost *:80> and <VirtualHost 192.0.2.1:80>).

Apache's VirtualHost config seems weird sometimes, but keep in mind that it dates back to a time before host-based virtualhosts existed and it was all IP-based. That makes it really sensitive to the <VirtualHost host:port> stuff.
[/code]

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group