Welcome! Log In Create A New Profile

Advanced

Re: How does 'locate' work?

Maxim Dounin
October 22, 2009 02:00PM
Hello!

On Thu, Oct 22, 2009 at 01:05:41PM -0400, GAZ082 wrote:

> Awesome article. Been trying to tune it up a little, and now i'm getting a 403 in the directory documents, here is my full site.com config:

Is 403 differs from what you expect?

403 is perfectly valid code, and it's returned by nginx in
serveral situations, including the following you may want to
check:

1. auth_basic specified in config, but specified
auth_basic_user_file doesn't exists

2. directory index requestd but not allowed (i.e. no index file in
directory, and autoindex not enabled)

Both should log reason in error_log at error level.

> server {
> listen 80;
> server_name www.site.com;
> #rewrite ^/(.*) http://site.com/$1 permanent;
> access_log /var/www/site.com/log/access.log;
> error_log /var/www/site.com/log/error.log;
>
>
>
> location / {
> root /var/www/site.com/public/;

It's probably a good idea to move root directive to server{}
level. This will save you some typing in each location.

> index index.html index.htm index.php;
>
> }
>
> location /documents {

Note that this matches anything that starts from "/documents",
including /documents.html and so on. Use "/documents/" to match
directory only.

> root /var/www/site.com/public;
> auth_basic "Access restricted.";
> auth_basic_user_file /var/www/site.com/private/pass;
> }

Otherwise looks perfectly correct. Note well that it has no index
directive, and therefore default index.html will be used.

If you expect this should have the same indices as in "location /",
you probably have to move index directive from "location /" to
server{} level as well.

> location ~ .php$ {

So your .php files in /documents/ won't be protected. See example
4 (as far as I remember numbering) in my previous message.

Maxim Dounin
Subject Author Posted

How does 'locate' work?

GAZ082 October 21, 2009 04:50PM

Re: How does 'locate' work?

Maxim Dounin October 21, 2009 07:38PM

Re: How does 'locate' work?

Jeff Waugh October 21, 2009 08:16PM

Re: How does 'locate' work?

Peter A Leonov October 22, 2009 03:12AM

Re: How does 'locate' work?

Artifex Maximus October 22, 2009 07:58AM

Re: How does 'locate' work?

Maxim Dounin October 22, 2009 09:30AM

Re: How does 'locate' work?

GAZ082 October 22, 2009 01:05PM

Re: How does 'locate' work?

Maxim Dounin October 22, 2009 02:00PM

Re: How does 'locate' work?

GAZ082 October 22, 2009 09:24PM

Re: How does 'locate' work?

Maxim Dounin October 23, 2009 02:50AM

Re: How does 'locate' work?

edogawaconan October 22, 2009 12:38AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 313
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