homepage Welcome to WebmasterWorld Guest from 54.163.72.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Load Balancer or any other Problems
anne10




msg:4229946
 1:51 pm on Nov 13, 2010 (gmt 0)

hi,

I am using hardware load balancer. my wesite name poiting to the loadbalancer ipaddress. In google when i give site:domain.com it return all my indexed page. when i give site:mydomain ipaddress (ie load balancr ipaddress) its also return the number of pages. Is anything I did wrong as gogole indexed like this?

domainname.com/1/xyz.html
domainname's ip address/1/xyz.html

both are going to same page. Please help me in this issus. Thanks in advance

 

sublime1




msg:4230063
 10:13 pm on Nov 13, 2010 (gmt 0)

If you use NameVirtualHost *:80, then create a virtual host having a ServerName domain.com on each of the web servers (running Apache, I assume) in the cluster behind your load balancer, your server should not respond with the site's web page using an IP address.

My assumption is that you have a single site on each of the servers behind the load balancer and are relying on the default host configuration.

It's also probably possible to configure the load balancer to prevent a response on the IP address (require a domain).

Tom

anne10




msg:4230455
 11:55 am on Nov 15, 2010 (gmt 0)

We are not using NameVirtualHost *;80

sublime1




msg:4230529
 3:02 pm on Nov 15, 2010 (gmt 0)

Anne --

If you cannot use named virtual hosts on the servers behind the load balancer (for some reason), and cannot configure your load balancer to reject requests not having the domain name, you could write a rewrite rule. While this is a widely used option, I believe it should generally be considered last, after other options have been considered. If you look at the totality of the threads here in this forum, you will quickly see that rewriting is a tricky thing to pull off!

But if I have not dissuaded you, the following should do the trick also. I'll assume you have access to the apache configuration, given your scenario. The same code will work in a .htaccess, but it is a less desirable solution if not required.


RewriteEngine On

RewriteCond %{REMOTE_HOST} [0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3}
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


This would respond with a 301 redirect, the user would get the corrected domain name, and is the fastest way to clean up the Google entries. FYI, you may want to add another RewriteCond if you don't have one elsewhere, in order to redirect non-www versions of your domain to the canonical www version, which might look like this:


RewriteEngine On

RewriteCond %{REMOTE_HOST} [0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3} [OR]
RewriteCond %{REMOTE_HOST} !^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


You may also want to set up a Google Webmaster Tools account (if you don't already have one) and claim ownership of all the variants, after which you'll have the option of declaring a preference within Google for how your domain results should be displayed.

Tom

jdMorgan




msg:4231013
 3:44 pm on Nov 16, 2010 (gmt 0)

The Remote_Host variable would indicate the IP address or hostname of the machine *sending* the HTTP request, so I'm not sure that that is what is needed here. Also, the IP-address test in the second rule above is redundant; If the hostname is an IP address, then by definition, it will not be the canonical hostname, making the first RewriteCond unnecessary. Finally, the second RewriteRule variant is capable of redirecting *all* non-canonical hostname requests including those in FQDN format and/or having appended port numbers, but only if the hostname pattern is end-anchored.

Taking all of these comments into consideration, I'd suggest:

RewriteEngine On
#
RewriteCond %{HTTP_HOST} ^[0-9]{1-3}(\.[0-9]{1-3}){3}
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

- or -

RewriteEngine On
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

However, proper VirtualHost configuration is the preferred solution, as stated above by sublime1. In that case, with the canonical-hostname VirtualHost explicitly defined, the default VirtualHost container can contain an unqualified redirect to the canonical hostname. Since the default container will only be used in cases where a non-canonical hostname is requested, the redirect will only be invoked for these non-canonical requests, and the explicit RewriteCond test of the hostname won't be needed, since that qualification function will have already been accomplished by the selection of the appropriate VirtualHost container.

Jim

[edit] Corrected as noted below. [/edit]

[edited by: jdMorgan at 2:00 am (utc) on Nov 30, 2010]

sublime1




msg:4231031
 4:10 pm on Nov 16, 2010 (gmt 0)

Oh crud. I always get HTTP_HOST confused with REMOTE_HOST.

Tom

jdMorgan




msg:4236527
 2:00 am on Nov 30, 2010 (gmt 0)

Yeah, and I often forget to allow for a blank hostname request... Now corrected above. :)

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved