I have it protected, but it’s prompting to login on every page, due to
the
piwik.php and piwik.js files (necessary for analytics) being in my
protected
directory. This is described on Piwik’s website, below.
“If you use HTTP Authentication (Basic or Digest) on your Piwik files,
you
should exclude piwik.php and piwik.js from this authentication, or
visitors
on your website would be prompted with the authentication popup.”
My question is: what kind of Nginx rule can I use to protect all files
in
that directory, besides those two? Is it possible to do a negative regex
match on a location block?
I have it protected, but it’s prompting to login on every page, due to the
piwik.php and piwik.js files (necessary for analytics) being in my protected
directory. This is described on Piwik’s website, below.
What actual requests are made that are challenged for
authentication? Check your access_log for http 401.
At a guess, it is just /analytics/piwik.js that you care about here.
So: add
location = /analytics/piwik.js {auth_basic off;}
inside your “location /analytics {}” block.
(This will try to serve the file “/var/www/piwik//piwik.js”, given the
above configuration.)
My question is: what kind of Nginx rule can I use to protect all files in
that directory, besides those two? Is it possible to do a negative regex
match on a location block?
It is usually simpler to use positive matching. The nginx “location”
rules usually let it be possible.