hi, 我想实现一个这样的功能,客户端发送请求,通过ngx.location.capture转发给一个fastcgi_pass的子请求,我的项目是codeigniter, 下面是基础配置
server {
listen 80;
server_name ci.me;
root html/ci;
index index.html index.php;
default_type text/html;
location / {
log_by_lua_block {
ngx.log(ngx.ERR, "try_files")
}
try_files $uri $uri/ /index.php;
}
location = /index.php {
log_by_lua_block {
ngx.log(ngx.ERR, "location capture")
}
access_by_lua_block {
ngx.say(ngx.var.request_uri)
local res = ngx.location.capture("/subrequest_fastcgi", {share_all_vars = true})
ngx.print(res.body)
}
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
#include fastcgi.conf;
}
location = /subrequest_fastcgi {http://ci.me/index.php/welcome/test
internal;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
路由类似于这样:
http://ci.me/index.php/welcome/test
这样会是404错误,
相应的错误日志如下:
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: ci.me, request: "GET /index.php/welcome/test HTTP/1.1", subrequest: "/subrequest_fastcgi", upstream: "fastcgi://127.0.0.1:9000", host: "ci.me"
请问,类似这样的功能,改怎么去实现,谢谢