SSI subrequest cannot work with "error page" directive?

Hi, I have discovered a situation where nginx can’t handle SSI
virtualtags right with “error page”:

nginx is configured to serve local files, then fallback to proxy
remotefile,and then stored in local through “proxy_store”:

root /cache/$host;
location / {
index index.shtml;
error_page 404 = /fetch$uri;
}
ssi on;
location /fetch {
internal;
proxy_pass http://backend;
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Via “s9/nginx”;
alias /cache/$host;
}
location ~ /$ {
index index.shtml;
error_page 403 404 = @fetch;
}
location @fetch {
internal;
proxy_pass http://backend;
proxy_store /cache/$host${uri}index.shtml;
proxy_store_access user:rw group:rw all:rw;
proxy_set_header Host $host;
proxy_set_header Via “s9/nginx”;
proxy_set_header X-Real-IP $remote_addr;
}

example, there is index.shtml,like:

..

nginx returns the page and then attempts to process the SSI virtual
tags. But, the virtual tags request can’t redirect “/fragment/1.ssi”
to internal location:
“/fetch”, it just report can’t find “/fragment/1.ssi” .
If I request the “/fragment/1.ssi” directly,
it works fine, it will proxy pass to backend,and store the content
into"/cache/host/fragment/1.ssi".

and, if I add:

location /fragment {
proxy_pass http://backend;

}

now, nginx will process index.shtml and return composed content right.

So,I wonder, does the subrequest to the SSI virtual tags can’t handle
“error page” directive?

I’m trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo

In article [email protected]
nightsailer[email protected] wrote:

Hi, I have discovered a situation where nginx can’t handle
SSIvirtualtags right with “error page”:

nginx is configured to serve local files, then fallback to
proxyremotefile,and then stored in local through “proxy_store”:

proxy_store_access user:rw group:rw all:rw;
internal;
proxy_pass http://backend;
proxy_store /cache/$host${uri}index.shtml;
proxy_store_access user:rw group:rw all:rw;
proxy_set_header Host $host;
proxy_set_header Via “s9/nginx”;
proxy_set_header X-Real-IP $remote_addr;
}

example, there is index.shtml,like:

...

nginx returns the page and then attempts to process the SSI virtual
tags. But, the virtual tags request can’t redirect “/fragment/1.ssi”
to internal location:
“/fetch”, it just report can’t find “/fragment/1.ssi” .
If I request the “/fragment/1.ssi” directly,
it works fine, it will proxy pass to backend,and store the content
into"/cache/host/fragment/1.ssi".

and, if I add:

location /fragment {
proxy_pass http://backend;

}

now, nginx will process index.shtml and return composed content
right.

So,I wonder, does the subrequest to the SSI virtual tags can’t
handle"error page" directive?

Ok, I think error_page directive not work with SSI subrequest,
but, there’s my alternate solution(more easy way):

set $index ‘index.shtml’;
set $store_file $request_filename;
if ($uri ~ /$ ){
set $store_file $request_filename$index;
rewrite (.*) $1index.shtml last;
}
location / {
index index.shtml;
proxy_store on;
proxy_temp_path /cache/temp;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Via “s9/nginx”;
proxy_store_access user:rw group:rw all:rw;
if ( !-e $store_file ) {
proxy_pass http://backend;
}
}

Now, all works fine, nginx is cool!

Sorry for my English, I’m Chinese,
for Sichuan earthquake victims:
Wish all injured people live through the baddest time.
I hope every things getting better…

I’m trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo