A
A
Alexey2015-11-20 19:22:30
Nginx
Alexey, 2015-11-20 19:22:30

Why doesn't the simplest path in nginx work?

Why is localhost/dev not working???

server {
    set $path "/media/sf_FunCollection";

    listen          1001;
    server_name     localhost;

    if ($http_user_agent ~* "(iphone|android|blackberry)") {
        rewrite ^ http://localhost:1100 redirect;
        break;
    }

  location / {
    root   $path/application;
    #index index.html;
    charset utf-8;
  }

  location /dev {
    root   $path/landings/run;
    #index index.html;
    charset utf-8;
  }

    location /api/v1 {
        proxy_set_header        X-Real-IP               $remote_addr;
        proxy_set_header        X-Forwarded-For         $proxy_add_x_forwarded_for;
        proxy_set_header        Host                    $host;
        proxy_pass              http://localhost:1437/api/v1;
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lynn "Coffee Man", 2015-11-21
@Murmurianez

You should always look at error.log first.
You also need to understand that the path to the file is added to `root`. Those. the query `localhost/dev/index.html` looks for the file `ROOT/dev/index.html`, which is often overlooked.
And the last, non-obvious moment, the `root` directive is stupid and if it does not see the slash `/` as the first character, then it considers the path relative to some default root. This is usually `/usr/share/nginx` or `/etc/nginx`. In your case, the root would be something like `/usr/share/nginx/media/sf_FunCollection`, which is probably wrong.

M
mikes, 2015-11-21
@mikes

maybe http:// localhost:1100

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question