Welcome! Log In Create A New Profile

Advanced

Static files logging off + directory access restriction

Posted by chrissp 
Static files logging off + directory access restriction
March 16, 2014 04:21AM
Hi,

I've recently switched from apache to nginx and I'm still struggling with a few minor details:

I dont want to log any static files for a particular vhost and I want to restrict the access to a particular directory and all subdirectories within it. So I have these lines in my vhost configuration file:


# Static files logging off
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml|html|txt)$ {
access_log off;
expires max;
}


# Restrict access to admin directory
location /admin/ {
auth_basic "Restricted Area";
auth_basic_user_file /etc/nginx/secret/admin.secret;

....
....
}


Access restriction works if I try to access http://example.com/admin/subdir/

but my problem is that when accessing e.g. http://example.com/admin/subdir/index.html I am not asked for any password and the file is displayed directly this is also valid for e.g. http://example.com/admin/subdir/picture.jpg

As soon as I remove the html and the jpg part for the static files logging segment I am asked for a password in both cases.

How do I have to change my configuration so that I do not log the files but am still asked for a password for any of those files within the access restricted folder?

Thanks for any help



Edited 1 time(s). Last edit at 03/16/2014 04:21AM by chrissp.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 212
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready