我正在尝试以递归方式为多个客户 ID 提供文件夹内容,以实现与我影响范围之外的相应应用程序的向后兼容性。我希望所有以 开头的 URL 路径都/<integer_customer_id>/<integer_display_id>/config/<whatever...>
为文件提供服务/var/cache/digsig/config/<whatever...>
。
这是我迄今为止尝试过的:
location ~ ^/[0-9]+/[0-9]+/config/ {
alias /var/cache/digsig/config/;
}
导致:
$ wget http://localhost:/993002/104/config/config.ini
--2016-12-07 12:08:57-- http://localhost/993002/104/config/config.ini
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://localhost/993002/104/config/config.ini/ [following]
--2016-12-07 12:08:57-- http://localhost/993002/104/config/config.ini/
Reusing existing connection to localhost:80.
HTTP request sent, awaiting response... 403 Forbidden
2016-12-07 12:08:57 ERROR 403: Forbidden.
日志显示:
2016/12/07 12:08:57 [error] 8232#8232: *4 directory index of "/var/cache/digsig/config/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET /993002/104/config/config.ini/ HTTP/1.1", host: "localhost"
为什么别名指令永久搬迁为什么最后会添加一个/
,破坏实际路径?请注意,我没有任何 return 301 ...
我的整个 Nginx 配置中的语句。