I would like to modify an existing Nginx location
block to serve an HTTP 403 status to any PHP files in the .well-known
directory and its subdirectories. I am using .well-known
for legitimate purposes, but a recent server compromise has shown I need to be a lot more strict on what's permitted.
My current Nginx location
block is:
location ^~ /.well-known/ {
allow all;
default_type "text/plain";
root /var/www/example.com/_well-known/;
try_files $uri/ $uri =404;
}
The root
is deliberately outside the public HTML directory (which is at /var/www/example.com/live/
if it's relevant).
How can I modify this block or provide an additional location
block to serve HTTP 403 to all PHP file requests under the .well-known
directory?
Thank you.
.well-known
, it's part of a list of measures I'm taking. There is no valid need (to my knowledge) to have PHP scripts in there so it's a belt-and-braces approach. Thank you for your perspective, I do appreciate it.