Welcome! Log In Create A New Profile

Advanced

Re: Location for any Host/ Server

basti
June 09, 2020 11:48AM
Does not work.

cat /etc/nginx/conf.d/git.conf
## Disable .htaccess and other hidden files
server {
listen 80 default_server;
server_name _;

location ~ /\.git {
return 404;
}

location ~ /\.(?!well-known).* {
deny all;
access_log off;
log_not_found off;
}
}

Result is, that http://example.com/test/.git/config is accessible.

On 09.06.20 17:16, Thomas Ward wrote:
> server {
>     listen 80 default_server;
>     server_name _;
>
>     ...
> }
>
>
> The above should do what you're after.  Specifies a default-server
> listener on port 80 and it matches that special catch-all that accepts
> all server_name results.  (though, default_server will match anything
> that doesn't match any other server_name Host so...)
>
>
> Thomas
>
> On 6/9/20 11:14 AM, basti wrote:
>> 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
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Location for any Host/ Server

basti June 09, 2020 11:16AM

Re: Location for any Host/ Server

Thomas Ward June 09, 2020 11:18AM

Re: Location for any Host/ Server

basti June 09, 2020 11:48AM

Re: Location for any Host/ Server

Thomas Ward June 09, 2020 12:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 68
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready