Is there a clean way of combining nginx location rules?
Unfortunately, no. There is no cleaner way, as explained here, here and in the documentation
But, you should probably use a separate file for your php configuration, that way, all you have to do is this:
location /private/ {
auth_basic "Restricted";
....
location ~ \.php$ {
include phpconf.conf;
}
}
location ~ \.php$ {
include phpconf.conf;
}