{"action":"created","issue":{"url":"https://api.github.com/repos/Mashape/kong/issues/594","labels_url":"https://api.github.com/repos/Mashape/kong/issues/594/labels{/name}","comments_url":"https://api.github.com/repos/Mashape/kong/issues/594/comments","events_url":"https://api.github.com/repos/Mashape/kong/issues/594/events","html_url":"https://github.com/Mashape/kong/issues/594","id":109972788,"number":594,"title":"Kong's interaction with binary nginx access modules","user":{"login":"smanolache","id":4068658,"avatar_url":"https://avatars.githubusercontent.com/u/4068658?v=3","gravatar_id":"","url":"https://api.github.com/users/smanolache","html_url":"https://github.com/smanolache","followers_url":"https://api.github.com/users/smanolache/followers","following_url":"https://api.github.com/users/smanolache/following{/other_user}","gists_url":"https://api.github.com/users/smanolache/gists{/gist_id}","starred_url":"https://api.github.com/users/smanolache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smanolache/subscriptions","organizations_url":"https://api.github.com/users/smanolache/orgs","repos_url":"https://api.github.com/users/smanolache/repos","events_url":"https://api.github.com/users/smanolache/events{/privacy}","received_events_url":"https://api.github.com/users/smanolache/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Mashape/kong/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"thefosk","id":964813,"avatar_url":"https://avatars.githubusercontent.com/u/964813?v=3","gravatar_id":"","url":"https://api.github.com/users/thefosk","html_url":"https://github.com/thefosk","followers_url":"https://api.github.com/users/thefosk/followers","following_url":"https://api.github.com/users/thefosk/following{/other_user}","gists_url":"https://api.github.com/users/thefosk/gists{/gist_id}","starred_url":"https://api.github.com/users/thefosk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thefosk/subscriptions","organizations_url":"https://api.github.com/users/thefosk/orgs","repos_url":"https://api.github.com/users/thefosk/repos","events_url":"https://api.github.com/users/thefosk/events{/privacy}","received_events_url":"https://api.github.com/users/thefosk/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-10-06T09:51:22Z","updated_at":"2015-11-02T13:13:17Z","closed_at":null,"body":"Hello,\r\n\r\nI have a custom nginx access module. It executes before the lua module and sometimes it returns HTTP_UNAUTHORIZED. When this happens I get no response whatsoever from Kong (no headers, no body, the http connection is just closed). I get the following error in the logs:\r\n\r\nfailed to run header_filter_by_lua*: /usr/local/share/lua/5.1/kong.lua:218: attempt to index field 'plugin' (a nil value)\r\n\r\nI suspect the following happens: the access_by_lua set by Kong is not executed any more => some ngx.ctx variables (ngx.ctx.api or ngx.ctx.stop_phases for example) are not set => they are checked/used later, for example in the {header|body}_filter_by_lua callbacks and, as they are not defined, those ngx.ctx variables cause errors in the lua interpreter.\r\n\r\nI have replaced `if not ngx.ctx.stop_phases then` by `if ngx.ctx.stop_phases ~= nil and not ngx.ctx.stop_phases then` in the exec_plugins_{header|body}_filter in kong.lua and now I'm getting normal responses from kong, i.e. I'm getting the 401 Unauthorized header with the corresponding error message from nginx.\r\n\r\nI propose that all kong lua callbacks check first for the existence of one ngx.ctx.api or ngx.ctx.plugin or ngx.ctx.stop_phases before taking action.\r\n"},"comment":{"url":"https://api.github.com/repos/Mashape/kong/issues/comments/153012704","html_url":"https://github.com/Mashape/kong/issues/594#issuecomment-153012704","issue_url":"https://api.github.com/repos/Mashape/kong/issues/594","id":153012704,"user":{"login":"smanolache","id":4068658,"avatar_url":"https://avatars.githubusercontent.com/u/4068658?v=3","gravatar_id":"","url":"https://api.github.com/users/smanolache","html_url":"https://github.com/smanolache","followers_url":"https://api.github.com/users/smanolache/followers","following_url":"https://api.github.com/users/smanolache/following{/other_user}","gists_url":"https://api.github.com/users/smanolache/gists{/gist_id}","starred_url":"https://api.github.com/users/smanolache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smanolache/subscriptions","organizations_url":"https://api.github.com/users/smanolache/orgs","repos_url":"https://api.github.com/users/smanolache/repos","events_url":"https://api.github.com/users/smanolache/events{/privacy}","received_events_url":"https://api.github.com/users/smanolache/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T13:13:17Z","updated_at":"2015-11-02T13:13:17Z","body":"I've created a pull request names \"Issue 594\" to address this issue."}}