【发布时间】:2017-05-05 14:21:14
【问题描述】:
我有 nginx 配置
它的一部分
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;
}
但是当我提出请求时,我有错误
2015/03/06 18:46:43 [错误] 11158#0: *1 opendir() “/home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/dashboar”失败 (2:没有这样的文件或目录),客户端:127.0.0.1,服务器:hub.dev, 请求:“GET /api/dashboard/doc/HTTP/1.1”,主机:“hub.dev”
或
2015/03/06 18:29:37 [错误] 9941#0: *1 opendir() "/home/dmac/www/hub/hub/modules/RestApi/Resources/Doc/consultan" 失败 (2 :没有这样的文件或目录),客户端:127.0.0.1,服务器:hub.dev,请求:“GET /api/consultant/doc/ HTTP/1.1”,主机:“hub.dev”
我尝试更改配置
location ~ ^/api/(consultant|dashboard)/doc/ {
但错误相同。
nginx版本:nginx/1.7.10 ubuntu 14.04 x64
为什么我有这个错误?怎么修? 您知道为处理不同模块配置 nginx 位置的其他方法吗?
【问题讨论】:
-
你试过以前的版本吗?可能是最新版本的新bug
-
不,我不尝试以前的版本。但是在我的家用电脑上,我有 nginx 1.4.6,我明天试试。可能这是解决我的问题。我在这里写下我的进度
-
我尝试使用 nginx 1.4.6。结果一样。但是,如果我禁用“自动索引”,则会出现错误 *3 目录索引“/home/dimon/www/symfony/crm.dev/src/Test/consultant”被禁止,客户端:127.0.0.1,服务器:crm .dev, request: "GET /test/consultant/doc/HTTP/1.1", host: "crm.dev" Nginx 可以访问这个目录。如果我启用“自动索引”,错误与问题相同(路径中没有最后一个字符)。
-
也许你可以用
root代替alias
标签: nginx