I spent quite a while today trying to figure out why my wordpress blog wouldn't work when a query string was added to the url. At first I just got an access denied error in the browser. Checking nginx's error log for the site in question I saw:
FastCGI sent in stderr: "Access to the script '/path/to/document_root/url' has been denied (see security.limit_extensions)" while reading response header from upstream
Searching for security.limit_extensions
, I found it was a php-fpm configuration option (so php-fpm.conf, not php.ini). Adding security.limit_extensions=
(so no value) to the php-fpm conf (and restarting php) I got a bit further. I now got a 404, and the error message in the nginx logs was:
FastCGI sent in stderr: "Unable to open primary script: /path/to/document_root/url (No such file or directory)" while reading response header from upstream
I then spent ages trying to figure out why it was trying to open this uri, instead of trying to open index.php as my try_files
dictated.
After a while I traced the error down to the use of if ($query_string...
within the location block for my blog. I remembered that I had actually had such an issue some time ago, and I'm pretty sure I spent ages trying to figure out the problem then too.
The problem is down to having the if
statement within the location block. Move it outside the location block and all is fine.
I also had trouble with mysql today, (installed the latest version, but got stuck in getting it setup). I haven't resolved that yet. I've asked for help on the mysql forums, so I'll see if any is forthcoming before I try and fix it myself. (It is likely to involve trial and error in setting options when compiling mysql and mysql is extremely slooow to configure, make and install).
The other thing I spent some time on was trying to get Firefox to send an If-Modified-Since
header. After some testing it only sends it if the cached response had a Last-Modified
header. I suspect that's per the spec, though I had naively thought that it might just use the Date
header in the absence of a Last-Modified
header.
I thought it would be nice if nginx could just set the Last-Modified
header for cacheable responses (that lack a Last-Modified
header) to the current time, but I couldn't find how to do this. And it's not a big deal really, I don't think many people request the same page more than once unless they're expecting it to be updated. If it was a big deal, then sending the Last-Modified
header from PHP would work fine.
No comments:
Post a Comment