Location for any Host/ Server

basti mailinglist at unix-solution.de
Tue Jun 9 15:14:20 UTC 2020


Hello,

i want to setup a location match for any hostname/servername like in apache:

cat /etc/apache2/conf-enabled/git.conf
RedirectMatch 404 /\.git

In nginx I try

cat /etc/nginx/conf.d/git.conf
server {
  ## Disable .htaccess and other hidden files
  location ~ /\.(?!well-known).* {
    deny all;
    access_log off;
    log_not_found off;
  }
}

But this does not match.
When I remove server {} i get nginx: [emerg] "location" directive is not
allowed here in /etc/nginx/conf.d/git.conf:2

I do not want to include my file into any server directive. It is asking
for trouble, how fast can you forget to add this?

best regards


More information about the nginx mailing list