Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On our site we automatically serve different content based on user's geolocation. To achieve this we pass variable with host's IP address to our fcgi application.

Problem is, we want to serve all of the content for search bots, so I would like to pass non-existent IP specially for these cases.

So far I've come up with this chunk of configuration code (as soon as nginx don't know about "else"):

location / {

  if ( $http_user_agent ~* Googlebot ) {
    set $remote_addr_googled "0.0.0.0";
  }

  if ( $http_user_agent !~* Googlebot ) {
    set $remote_addr_googled $remote_addr;
  }

  fastcgi_param REMOTE_ADDR $remote_addr_googled;

}

Аre there any other, more effective, ways around?

share|improve this question
    
danlefree provided really useful link about cloaking and geolocation as Google sees it. Guess we'll consider changing the way we treat search bots now. Anyway, I'm still interested in finding more effective ways to redefine nginx parameters based on some condition. –  smugglerFlynn Oct 21 '10 at 14:55
add comment

1 Answer

up vote 0 down vote accepted

The key is to treat Googlebot as you would a typical user from a similar location, IP range, etc. (i.e. don't treat Googlebot as if it came from its own separate country—that's cloaking).

Official Google Webmaster Blog: How Google defines IP delivery, geolocation, and cloaking

Update: You can use the nginx embedded perl module for if/then/else conditionals.

share|improve this answer
    
@smugglerFlynn - I'd be hesitant incorporate any spider-specific rules (if only for the fact that it's more work with questionable benefit if the same information is immediately available on a more specific URI) –  danlefree Oct 21 '10 at 14:57
    
yeah, thanks, you are right on this. We decided to make a separate page, with listing of all geolocation-dependant items available on site at once. Still, it would be great to know more ways (if any) to specifically redefine variables in nginx, not just for this particular case –  smugglerFlynn Oct 23 '10 at 11:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.