Hi All,
At beginning, I already implemented some lua cgi and run it on uhttpd well.
I added lua_prefix at uhttpd.conf, like
# uhttpd.conf
list lua_prefix '/test =/usr/lib/lua/test/index.lua'
# cgi at /usr/lib/lua/test/
root@OpenWrt:/usr/lib/lua/test# ls
example.lua index.lua utils.lua
# request
# curl -v -k "https://127.0.0.1/test/example"
> GET /test/example HTTP/1.1
> Host: 127.0.0.1
> User-Agent: curl/7.66.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: Keep-Alive
< Keep-Alive: timeout=20
< ETag: "44e-1-5f61bcdf"
< Last-Modified: Wed, 16 Sep 2020 07:21:03 GMT
< Date: Wed, 16 Sep 2020 07:23:54 GMT
< Content-Type: text/html
< Content-Length: 1
<
Now, I want to porting this to ngnix+uwsgi web server.
I added some configs, like
#
root@OpenWrt:~# cat /etc/uwsgi/vassals/luci-test_io.ini
[uwsgi]
strict = true
if-not-env = UWSGI_EMPEROR_FD
socket = /var/run/luci-test_io.socket
chmod-socket = 666
cheap = true
end-if =
plugin = cgi
cgi-mode = true
cgi = /www
chdir = /usr/lib/lua/test/
buffer-size = 10000
reload-mercy = 8
max-requests = 2000
limit-as = 200
reload-on-as = 256
reload-on-rss = 192
no-orphans = true
post-buffering = 8192
socket-timeout = 120
thunder-lock = true
plugin = syslog
disable-logging = true
req-logger = syslog:uwsgi-luci-test_io
log-format=%(method) %(uri) => return %(status) (%(rsize) bytes in %(msecs) ms)
chmod-socket = 666
cgi-safe = /usr/libexec/cgi-io
cgi-dontresolve = true
cgi-close-stdin-on-eof = true
cheap = true
idle = 360
# add /test folder at /etc/nginx/luci_uwsgi.conf
location /test/ {
index index.lua;
include uwsgi_params;
uwsgi_param SERVER_ADDR $server_addr;
uwsgi_modifier1 9;
uwsgi_pass unix:////var/run/luci-test_io.socket;
}
When I do request /test/example, I always got Not Found.
Questions:
- Is it possible to run lua cgi on nginx+uwsgi web service and expect the behavior just same as uhttpd?
- If Q1 is no, is there an example to try?
- If Q1 is yes, which part is wrong?
Please help. Thanks.