2023/04/01 17:15:02 [error] 2832#2832: *6 open() "/usr/local/openresty/nginx/html/api/item/1001" failed (2: No such file or directory), client: 192.168.6.1, server: localhost, request: "GET /api/item/1001 HTTP/1.0", host: "nginx-cluster", referrer: "http://localhost/item.html?id=1001"
2023/04/01 17:15:04 [error] 2832#2832: *7 open() "/usr/local/openresty/nginx/html/api/item/1001" failed (2: No such file or directory), client: 192.168.6.1, server: localhost, request: "GET /api/item/1001 HTTP/1.0", host: "nginx-cluster", referrer: "http://localhost/item.html?id=1001"
2023/04/01 17:15:06 [error] 2832#2832: *8 open() "/usr/local/openresty/nginx/html/api/item/1001" failed (2: No such file or directory), client: 192.168.6.1, server: localhost, request: "GET /api/item/1001 HTTP/1.0", host: "nginx-cluster", referrer: "http://localhost/item.html?id=1001"
2023/04/01 17:15:20 [error] 2832#2832: *9 open() "/usr/local/openresty/nginx/html/api/item/1001" failed (2: No such file or directory), client: 192.168.6.1, server: localhost, request: "GET /api/item/1001 HTTP/1.0", host: "nginx-cluster", referrer: "http://localhost/item.html?id=1001"
解决方案:
检查location后是否缺少符号 ~
location ~ /api/item/(\d+) {
# 默认的响应类型
default_type application/json;
# 响应结果由lua/item.lua文件来决定
content_by_lua_file lua/item.lua;
}