Nginx Cache and WP canonical URL create infinite loop

Davide D'Amico davide.damico at contactlab.com
Fri Nov 25 09:22:05 UTC 2011


> 
> ------------------------------
> 
> Message: 9
> Date: Thu, 24 Nov 2011 14:17:44 +0400
> From: Maxim Dounin <mdounin at mdounin.ru>
> To: nginx at nginx.org
> Subject: Re: Nginx Cache and WP canonical URL create infinite loop
> 	(bug ?)
> Message-ID: <20111124101744.GA95664 at mdounin.ru>
> Content-Type: text/plain; charset=us-ascii
> 
> Hello!
> 
> On Thu, Nov 24, 2011 at 09:50:10AM +0100, Simone Fumagalli wrote:
> 
>> On 11/23/2011 06:41 PM, Maxim Dounin wrote:
>>> With this config, the cache key for the request to
>>> "http://www.mysite.com/my-page//" will be
>>> "http://ALL_backend/my-page//".
>> 
>> Well, I was wrong. In another file, on main level, I've
>> 
>> 	proxy_cache_key "$scheme://$host$request_uri";
> 
> With this proxy_cache_key the key (for the same request) will be 
> "http://www.mysite.com/my-page//".
> 
> Maxim Dounin
> 

Hi, this is the situation:
dave at therock:~> uname -a
FreeBSD therock.office.lan 8.2-STABLE FreeBSD 8.2-STABLE #0: Sat Aug 27 08:47:51 CEST 2011     root at therock.office.lan:/usr/obj/usr/src/sys/THEROCK  amd64
dave at therock:~> pkg_info | grep -i nginx
nginx-1.0.10_1,1    Robust and small WWW server
dave at therock:/usr/ports/www/nginx> sudo make showconfig | grep '=on'
     HTTP_MODULE=on "Enable HTTP module"
     HTTP_CACHE_MODULE=on "Enable http_cache module"
     HTTP_GEOIP_MODULE=on "Enable http_geoip module"
     HTTP_REWRITE_MODULE=on "Enable http_rewrite module"
     HTTP_SSL_MODULE=on "Enable http_ssl module"
     HTTP_STATUS_MODULE=on "Enable http_stub_status module"
     CACHE_PURGE_MODULE=on "3rd party cache_purge module"
     HEADERS_MORE_MODULE=on "3rd party headers_more module"
dave at therock:/usr/ports/www/nginx> 

proxy_cache_path /usr/local/www/cache/myhost levels=1:2 keys_zone=MYHOST:125m inactive=24h max_size=2g;

server {
  listen 80;
  access_log    /var/log/nginx/myhost-test-access.log upstream;
  error_log     /var/log/nginx/myhost-test-error.log;
  server_name   myhost.foo.bar;

  proxy_redirect     off;
  proxy_set_header   Host             $host;
  proxy_set_header   X-Real-IP        $remote_addr;
  proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  proxy_store_access   user:rw  group:rw  all:r;
  proxy_max_temp_file_size   0;
  proxy_cache_key "$scheme://$host$request_uri";
  proxy_intercept_errors on;
  
  proxy_ignore_headers "Expires" "X-Accel-Expires" "Cache-Control";
  proxy_connect_timeout      10;
 
  location ~ /purge(/.*) {
    allow              127.0.0.1;
    allow              172.16.16.189;
    deny               all;
    proxy_cache_purge  MYHOST "$scheme://$host$1$is_args$args";
  }


  location / {
    proxy_cache MYHOST;
    proxy_cache_valid 200 1h;
    proxy_cache_valid 404 30m;
    proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
    proxy_pass http://172.16.16.227:80;
  }
}

then I'm requesting the following url (2 times):
[dave at ext ~]$ wget "http://myhost.foo.bar/tomato//#"
--2011-11-25 10:18:20--  http://myhost.foo.bar/tomato//
[…]

100%[======================================>] 10          --.-K/s   in 0s      

2011-11-25 10:18:20 (778 KB/s) - `index.html' saved [10/10]

[dave at ext ~]$ 

In the cache folder I see:
root at therock:/usr/local/www/cache/myhost# more 9/75/2d047ea530c6f984d115c0b9fd23c759 
Bk<CF>N^@^@^@^@<FF><FF><FF><FF><FF><FF><FF><FF>2]<CF>N^@^@^@^@M<A0>A<91>^@^@Z^@i^A^@^@^@^@^@^@
KEY: http://myhost.foo.bar/tomato//
HTTP/1.1 200 OK
Date: Fri, 25 Nov 2011 09:17:38 GMT
Server: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8 with Suhosin-Patch mod_perl/2.0.5 Perl/v5.12.4
X-Powered-By: PHP/5.3.8
Content-Length: 10
Connection: close
Content-Type: text/html

1322212658
root at therock:/usr/local/www/cache/myhost# 

And it seems that the key has a wrong value, isn't?

Thanks in advance,
d.


More information about the nginx mailing list