# New to web

**URL:** <https://www.ruby-forum.com/t/new-to-web/237789>\
**Category:** NGINX\
**Created:** [November 29, 2013, 5:59pm UTC](https://www.ruby-forum.com/t/new-to-web/237789 "2013-11-29T17:59:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [November 29, 2013, 5:59pm UTC](https://www.ruby-forum.com/t/new-to-web/237789/1 "2013-11-29T17:59:58Z")

</div>

Hi guys i’m very new to web dev, and getting started with nginx i just  
wanted to ask a few things.

Location blocks. Is the idea here to have as many location blocks as  
you have web pages? if a location has many files in it will nginx  
search if the requested file is in that location? i put a file  
“flood.jpg” inside my default root location (below) but i get  
permission denied when trying to access the file on my web browser. I  
do however see my nginx index homepage. To see “flood.jpg” do i need  
to add something to this block?

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

```

i also made a file in my root html folder: html/test/filename.html

This is also permission denied, but i want to ask. Is it ok accessing  
files like this or would it be better to make a specific location  
block for them, like:

location /test/filename.html  
or  
location /test/

should it be INSIDE the root location block: location /  
or should it be a separate block?

---

<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:** [November 30, 2013, 12:28am UTC](https://www.ruby-forum.com/t/new-to-web/237789/2 "2013-11-30T00:28:23Z")

</div>

On Fri, Nov 29, 2013 at 04:59:24PM +0000, Matthew Ngaha wrote:

Hi there,

One of the best things you can learn about is your server error log.

Read that, and it should tell you why nginx thinks something failed,  
every time.

> Location blocks. Is the idea here to have as many location blocks as  
> you have web pages?

The documentation for the directive “location” is at  
[http://nginx.org/r/location](http://nginx.org/r/location)

Briefly, when a request comes in, nginx picks only one location to  
process it, and nginx does whatever that location says.

The default action is “serve a file from the filesystem”. So if all you  
want to do is send files from the filesystem, you don’t need any  
location;  
or you can use one location that will match all requests.

> i put a file  
> “flood.jpg” inside my default root location (below) but i get  
> permission denied when trying to access the file on my web browser.

What does the error log say?

It should tell you which file nginx tried to open, and it should tell  
you why it failed.

(My guess is “Permission denied”, which indicates that the user that  
nginx runs as does not have permission to read the file. If that is the  
case, you will want to change something about your system – possibly  
the method by which you put the file there, or possibly the user account  
that nginx runs as.)

> This is also permission denied, but i want to ask. Is it ok accessing  
> files like this or would it be better to make a specific location  
> block for them, like:

From the list of location blocks that you have, you should be able to  
say which one will be used for each request that is made.

I tend to have one location block for one different type of request  
– and all requests of the form “serve from the filesystem below  
/usr/local/nginx/html” are the same type.

## f

Francis D. removed\_email\_address@domain.invalid
