Dmytro
Dmytro

Reputation: 582

nginx alias in location - lost last character

I have nginx config

its part

location ~ ^/api/(?<module>.+)/doc/ {
    autoindex on;
    index index.html;
    alias /home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/$1;
    error_log /var/log/nginx/hub-test-error.log debug;
}

But when i make request, i have error

2015/03/06 18:46:43 [error] 11158#0: *1 opendir() "/home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/dashboar" failed (2: No such file or directory), client: 127.0.0.1, server: hub.dev, request: "GET /api/dashboard/doc/ HTTP/1.1", host: "hub.dev"

OR

2015/03/06 18:29:37 [error] 9941#0: *1 opendir() "/home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/consultan" failed (2: No such file or directory), client: 127.0.0.1, server: hub.dev, request: "GET /api/consultant/doc/ HTTP/1.1", host: "hub.dev"

I try change config

    location ~ ^/api/(consultant|dashboard)/doc/ {

but error the same.

nginx version: nginx/1.7.10 ubuntu 14.04 x64

Why i have this error? How fix it? Do you know any oter way to configure nginx location for process different modules?

Upvotes: 2

Views: 1071

Answers (2)

user7967038
user7967038

Reputation:

There was error in nginx version 1.7.10

In the latest versions thi error fixed. So just update nginx.

Upvotes: 2

h0ru5
h0ru5

Reputation: 517

I had the same problem, solved it by appending a slash to the path in the alias directive.

alias /home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/$1/;

instead of

 alias /home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/$1;

I'd stab a guess that some code tries to remove a trailing slash but did end up eating every last character.

Upvotes: 2

Related Questions