# Help for my first steps with nginx as a proxy

## Whitewolf Fox

Hi everyone,

I'm just starting with nginx. I know, there are many tutorials out there, but I just do not find this kind of issue or even the single steps explained well enough to make me understand why this setup is not working:

I configured a server, listening on 8080 with two location blocks in there:

```

server {

        listen 85.25.153.14:8080;

        server_name move.marc-richter.info;

        keepalive_timeout 60;

        access_log /var/log/nginx/move.marc-richter.info-8080_access.log combined;

        error_log /var/log/nginx/move.marc-richter.info-8080_error.log info;

        root /var/www/localhost/htdocs;

        location / {

        }

        location /test {

                root /var/www/localhost/htdocs2;

        }

        location = /favicon.ico {

          return 204;

          access_log     off;

          log_not_found  off;

        }

}

```

The third location block is just in there to quieten my logs in case of not found favicon.ico file.

As far as I understand nginx config, this should do the following:

Serving index.html from /var/www/localhost/htdocs/index.html when someone opens move.marc-richter.info:8080.

Serving index.html from /var/www/localhost/htdocs2/index.html when someone opens move.marc-richter.info:8080/test.

The first one is working OK. But with the second one, I get 404 shown and the following is written to the logs:

```
==> move.marc-richter.info-8080_error.log <==

2014/05/26 22:48:15 [info] 882#0: *6 client 80.187.106.136 closed keepalive connection

2014/05/26 22:48:27 [error] 882#0: *7 open() "/var/www/localhost/htdocs2/test" failed (2: No such file or directory), client: 80.187.106.136, server: move.marc-richter.info, request: "GET /test HTTP/1.1", host: "move.marc-richter.info:8080"

==> move.marc-richter.info-8080_access.log <==

80.187.106.136 - - [26/May/2014:22:48:27 +0200] "GET /test HTTP/1.1" 404 162 "-" "Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.17"

```

I do not get why the location's path is appended to the document root here (/var/www/localhost/htdocs2/test) and do expect that connections to the location /test are served from within /var/www/localhost/htdocs2 directly. Could someone please explain what I am doing wrong?

I do have more questions, since this is the very first step. But I think it's worth to understand this one first and retry to think about the other points once I have understood this.

----------

## Whitewolf Fox

noone?

----------

## VBart

You've spent more time in asking this question, instead of just read the docs: http://nginx.org/r/root

 *Quote:*   

> A path to the file is constructed by merely adding a URI to the value of the root directive.

 

----------

## Whitewolf Fox

Sorry, I realized that I have asked unclear.

I'm aware why /test is appended to my root.

What I do not understand is the use of this behavior and how to achieve what I'm trying to do with it: I'd like to configure something, which acts like the Apache's aliases. For example, I'd like to achieve with nginx what this apache config does:

```

DocumentRoot /var/www/localhost/htdocs/

ServerName      move.marc-richter.info

<Directory "/var/www/localhost/htdocs/">

        Options -Indexes -ExecCGI FollowSymLinks MultiViews

        AllowOverride All

        Order allow,deny

        allow from all

</Directory>

Alias /test/   "/var/www/localhost/htdocs2/"

Alias /test    "/var/www/localhost/htdocs2/"

<Directory /var/www/localhost/htdocs2/>

        Options -Indexes FollowSymLinks MultiViews

        AllowOverride None

        Order allow,deny

        allow from all

</Directory>

```

Accessing move.marc-richter.info/test would now serve an index document from /var/www/localhost/htdocs2/ , not append /test to /var/www/localhost/htdocs2/test . I thought location is nginx's answer to this - can you tell me how to do it instead of this directive?

----------

