question about proxy_store

eliott eliott at cactuswax.net
Tue Jan 29 06:06:25 MSK 2008


I actually tested both methods presented above, and got them both to work.


########
method 1 was copied nearly verbatim from Igor's example.
Thanks Igor!

        location / {
          root /var/www/data/example.com/fetch;
          error_page 404 = /fetch$uri;
        }

        location  ^~ /fetch/ {
          internal;
          include  proxy.conf;
          proxy_set_header  X-Real-IP $remote_addr;
          proxy_pass http://127.0.0.1:9001;
          proxy_store /var/www/data/example.com$uri;
          proxy_store_access user:rw group:rw all:r;
        }

        location ~ /$ {
          index   index.html;
          root /var/www/data/example.com/fetch;
          error_page 403 404 = @fetch;
        }

        location @fetch {
          internal;
          include  proxy.conf;
          proxy_set_header  X-Real-IP $remote_addr;
          proxy_pass http://127.0.0.1:9001;
          proxy_store /var/www/data/example.com/fetch${uri}index.html;
          proxy_store_access user:rw group:rw all:r;
        }


########
Method 2 required some minor adjustment
Thanks Volodymyr!

        location / {
          root /var/www/data/example.com/fetch;
          if (-f $request_filename/_cache.html) {
              rewrite (.*) $1/_cache.html;
          }
          error_page 403 404 = /fetch$uri;
        }

        location  ^~ /fetch/ {
          internal;
          include  proxy.conf;
          proxy_set_header  X-Real-IP $remote_addr;
          proxy_pass http://127.0.0.1:9001;
          proxy_store /var/www/data/example.com${uri}_cache.html;
          proxy_store_access user:rw group:rw all:r;
        }

########

I am not sure which method is better. The first method results in a
proper site structure that you could tar up and move to another box,
or serve from another webserver, and it would be functional.

The second method is shorter and simpler, while it is tied more
closely to custom rewrite rules and an odd file extension.

I think for now I want the first method, for the ability to be more
highly portable.
I can rsync the output around if I want to.

Thanks for all the help in this thread.
It was a nice first experience on the mailing list for me.
:)





More information about the nginx mailing list