Hi Emmanuel, Hmm, must have missed that bit! But thanks, this was indeed the problem! I've setup another proxy in front with just the rewriting and now it works like a charm! Cheers, Raymond -----Original Message----- From: Emmanuel Bailleul [mailto:Emmanuel.Bailleul@xxxxxxxxxxx] Sent: maandag 1 februari 2010 10:02 To: users@xxxxxxxxxxxxxxxx Subject: RE: Apache reverse proxy / mod_rewrite behaviour > -----Message d'origine----- > De : Raymond Zeilstra [mailto:Raymond@xxxxxxxxxxxxx] Envoyé : vendredi > 29 janvier 2010 10:49 À : users@xxxxxxxxxxxxxxxx Objet : > Apache reverse proxy / mod_rewrite behaviour > > > > Hello, > > I'm trying to redirect visitors from certain countries using GeoIP. > I'm using Apache reverse proxy and pound as loadbalancer: > > Ubuntu Server 9.01 64bits > Apache 2.2.11 (mod_proxy, mod_proxy_http, mod_cache, mod_disk_cache, > mod_rewrite, mod_geoip) > > The problem I'm encountering is that the first time a request is being > rewritten and redirected, but after a few times it's ignoring the > rewrite rules. > Here's the Apache config: > > <Virtualhost 1.2.3.4:80> > > GeoIPEnable On > GeoIPScanProxyHeaders On > GeoIPDBFile /www/GeoIP.dat > > RewriteEngine On > > RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(nl|be)$ [NC] RewriteCond > %{HTTP_HOST} !^(nl|be)\.domain\.com$ [NC] RewriteRule ^(.*)$ > http://www.domain.com/$1 [L] > > LogFormat "%{X-Forwarded-For}i %{Host}i %l %u %t \"%r\" %>s %b > \"%{Referer}i\" \"%{User-Agent}i\" %D" > TransferLog /apache/logs/www.domain.com.access.log > ErrorLog /apache/logs/www.domain.com.error.log > > ProxyRequests Off > > <Proxy *> > Order deny,allow > Allow from all > </Proxy> > > ProxyPass / http://127.0.0.1:8080/ > ProxyPassReverse / http://127.0.0.1:8080/ ProxyPreserveHost On > > CacheRoot /cachedisk > CacheEnable disk / > CacheMaxFileSize 10000000 > CacheDirLevels 5 > CacheDirLength 1 > CacheDisable www.domain.com > > </Virtualhost> > > Now a wget gives me the following result with an empty disk cache: > > # wget http://nl.domain.com/ > Resolving nl.domain.com... 1.2.3.4 > Connecting to nl.domain.com|1.2.3.4|:80... connected. > HTTP request sent, awaiting response... 302 Found > Location: http://www.domain.com// [following] Resolving > www.domain.com... 1.2.3.4 ... > > This is what I want, but after 2 or 3 times and I assume the request > is being cached, then this happens: > > # wget http://nl.domain.com/ > Resolving nl.domain.com... 1.2.3.4 > Connecting to nl.domain.com|1.2.3.4|:80... connected. > HTTP request sent, awaiting response... 200 OK > Length: 36330 (35K) [text/html] > Saving to: `index.html' > > Also in the first case the request is being logged in the Apache > access log, but the second one I can't even find in the access logs. > So my question is why does the rewriting work with a clean cache disk, > but doesn't if (at least I assume) data is returned from the disk > cache and why isn't there a log entry in the access log in the latter case ? > > I hope someone has any ideas where I'm going wrong! > > Thanks, > Raymond > Maybe : http://httpd.apache.org/docs/2.2/caching.html#overview (...) This means that any other stages that might ordinarily happen in the process of serving a request -- for example being handled by mod_proxy, or mod_rewrite -- won't happen. But then this is the point of caching content in the first place. (...) Emmanuel --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.432 / Virus Database: 271.1.1/2645 - Release Date: 01/31/10 19:35:00 --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx