New to web

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?

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

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. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs