I have a openresty+php setup.
And in the openresty conf, I have the php location block configured like this:
location ~ [^/]\.php(/|$) {
# Setup caching (Page Speed)
set $is_php 1;
add_header X-srcache-status $srcache_fetch_status;
the is_php is initialized to 0 in the server block.
What I'm planning to do here with the is_php variable is I want to tell whether a request is finally handled by the php location block. (Not sure whether I'm doing it in the right way, any suggestion/recommendation for detecting the location block would be highly appreciated)
I can use `if ngx.var.is_php == "1"` in most cases, however, I discovered that if there's something wrong in the php and it returns a 500 error, the is_php will be set to 0 and there won't be such `X-srcache-status` header in the response. What's happening here?
BTW, I also found some other weird behaviours of openresty which I can't explain.
1. I initially tried to use `if ngx.header["x-srcache-status"] ~= nil` to test whether the request is handled by the php location block (because it's added by the location block), however, it looks like ngx.header["x-srcache-status"] is always nil (also tried capitalized X, but same), but I can see it from the response! Any idea why?
2. I tried to log the response headers in header_filter_by_lua using `for k,v in pairs(ngx.header)`, but couldn't get anything, any thoughts?
3. why `ngx.var.is_php` has to be treated as a string, i.e. `ngx.var.is_php == "1"` not `ngx.var.is_php == 1`? Even I set it to be 1, not "1"?
Thanks & Best Regards
House