Forking to any type of program is a big 'no' in the nginx world, what you need to do is adopt a fcgi interface, look at how PHP with php-cgi works (tcpip port or socket) with either a fast-cgi or proxy-pass API.
Better yet, if you switch over to Lua (with or without ffi) you will get near fast performance as nginx does by default.
Better yet, if you switch over to Lua (with or without ffi) you will get near fast performance as nginx does by default.