Hi, I've just started playing with OpenResty and I'm puzzled by some behavior that seems to contradict the docs. I wanted to include
access_by_lua and
content_by_lua directives in the same location block, and the docs seem to indicate that if I call
ngx.exit(ngx.OK) from my
access_by_lua block, it should continue to the content handler (http://wiki.nginx.org/HttpLuaModule#access_by_lua):
Note that when calling ngx.exit(ngx.OK)
within a access_by_lua handler, the nginx request processing control flow will still continue to the content handler.
But when I run the following nginx.conf, I never get to the content handler (it doesn't change if I remove the line calling ngx.exit()):
curl -v http://localhost:8098/
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 8098 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:8098
> Accept: */*
>
< HTTP/1.1 200 OK
* Server openresty/1.7.10.1 is not blacklisted
< Server: openresty/1.7.10.1
< Date: Wed, 26 Aug 2015 20:08:32 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
<
In access handler
* Connection #0 to host localhost left intact
Here is my nginx.conf:
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
lua_package_path 'conf/?.lua;;';
server {
listen 8098;
location / {
default_type text/html;
access_by_lua '
ngx.say("In access handler")
ngx.exit(ngx.OK)
';
content_by_lua '
ngx.say("In content handler")
';
}
}
}