# Location{} hassles:(

**URL:** <https://www.ruby-forum.com/t/location-hassles/237892>\
**Category:** NGINX\
**Created:** [December 5, 2013, 2:11am UTC](https://www.ruby-forum.com/t/location-hassles/237892 "2013-12-05T02:11:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [December 5, 2013, 2:11am UTC](https://www.ruby-forum.com/t/location-hassles/237892/1 "2013-12-05T02:11:41Z")

</div>

Hey all I can’t seem to get the hang of how to use/write location  
blocks. I have mailed the list before and I do understand how it works  
but what I’ve tried fails.

I have tried a few things and in both cases i don’t think what i’m  
doing is making a difference. Here they are:

```
                          http://bpaste.net/show/YXFXLuJ1Uc1UFQDc8ctn/

```

The 1st test was to put location {} nested into the main location {}  
that was already in nginx.conf. I put the “deny all;” just to see if  
it would find or ignore/ my new location {} but the nested location  
test directory/file isn’t denying access.

The 2nd location {} test is below the main one. In the installed  
nginx folder it uses html/ as the root, i tried to create a test  
“delete” folder as an alternative location to the html root folder but  
i can’t seem to get it right. My browser returns a “404 Not Found”  
when i try to access files in localhost/delete.

In both cases my added locations {} are being ignored. Any ideas what i  
can do?

---

<div class="post-metadata">

**Author:** ![Matthew\_Ngaha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Matthew\_Ngaha](https://www.ruby-forum.com/u/Matthew_Ngaha)\
**Post date:** [December 5, 2013, 4:04pm UTC](https://www.ruby-forum.com/t/location-hassles/237892/2 "2013-12-05T16:04:19Z")

</div>

Hello!

On Thu, Dec 05, 2013 at 01:10:53AM +0000, Matthew Ngaha wrote:

> that was already in nginx.conf. I put the “deny all;” just to see if  
> it would find or ignore/ my new location {} but the nested location  
> test directory/file isn’t denying access.
> 
> The 2nd location {} test is below the main one. In the installed  
> nginx folder it uses html/ as the root, i tried to create a test  
> “delete” folder as an alternative location to the html root folder but  
> i can’t seem to get it right. My browser returns a “404 Not Found”  
> when i try to access files in localhost/delete.
> 
> In both cases my added locations {} are being ignored. Any ideas what i can do?

Try looking into error log and full config, and make sure you’ve  
reloaded configuration after changing it.

With the config you’ve posted, i.e.:

```
    location / {
        root html;
        index index.html index.htm;

        location /test/file.html {
            deny all;
        }
    }

```

location /delete {  
root delete;  
}

and assuming there are no other locations defined, expected  
results are:

request to /foo maps to file /html/foo  
request to /test/files.html returns 403  
request to /delete/foo maps to file /delete/delete/foo

See here for documentation:

[http://nginx.org/r/location](http://nginx.org/r/location)  
[http://nginx.org/r/root](http://nginx.org/r/root)

–  
Maxim D.  
[http://nginx.org/en/donation.html](http://nginx.org/en/donation.html)
