Welcome! Log In Create A New Profile

Advanced

Re: Nginx Directory Listing - Restrict by IP Address

Francis Daly
May 18, 2018 12:38PM
On Fri, May 18, 2018 at 08:05:34AM +0800, Sathish Kumar wrote:

Hi there,

> We have a requirement to allow directory listing from few servers and
> disallow from other ip addresses and all IP addresses should be able to
> download all files inside the directory.

"Directory listings" is presumably only relevant when the request url
ends in /.

So if you have "autoindex on", then all you need to do is disallow some
IP addresses from accessing those urls.

> location / {
> root /downloads;
> autoindex on;
> allow 1.1.1.1;
> deny all;
> }

Replace the allow/deny part with

location ~ /$ {
allow 1.1.1.1;
deny all;
}

and it should do what you want.

The end result is: request ends in / --> check the allow list; otherwise,
allow as normal.

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx Directory Listing - Restrict by IP Address

Sathish Kumar May 17, 2018 08:08PM

Re: Nginx Directory Listing - Restrict by IP Address

prajitth May 18, 2018 02:18AM

Re: Nginx Directory Listing - Restrict by IP Address

Sathish Kumar May 18, 2018 02:38AM

Re: Nginx Directory Listing - Restrict by IP Address

wickedhangover May 18, 2018 07:20AM

Re: Nginx Directory Listing - Restrict by IP Address

Igor A. Ippolitov May 18, 2018 08:18AM

Re: Nginx Directory Listing - Restrict by IP Address

Sathish Kumar May 18, 2018 09:04AM

Re: Nginx Directory Listing - Restrict by IP Address

Igor A. Ippolitov May 18, 2018 11:12AM

Re: Nginx Directory Listing - Restrict by IP Address

Sathish Kumar May 18, 2018 12:34PM

Re: Nginx Directory Listing - Restrict by IP Address

Igor A. Ippolitov May 18, 2018 01:04PM

Re: Nginx Directory Listing - Restrict by IP Address

Sathish Kumar May 18, 2018 09:40PM

Re: Nginx Directory Listing - Restrict by IP Address

Sathish Kumar May 19, 2018 12:02AM

Re: Nginx Directory Listing - Restrict by IP Address

Sathish Kumar May 18, 2018 08:58AM

Re: Nginx Directory Listing - Restrict by IP Address

Anoop Alias May 18, 2018 09:04AM

Re: Nginx Directory Listing - Restrict by IP Address

Francis Daly May 18, 2018 12:38PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 302
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready