Feature Req: Include Pipe

Jonathan Dance jd at wuputah.com
Mon Oct 2 22:07:19 MSD 2006

Hello again,

I was wondering what people might think about adding pipe support to
the include directive (yes, I'm a config file junkie). This might be a
good alternative to using the internal nginx variables - people could
simply use a language of their choice (via the shebang line) to
execute a script which would output their desired configuration.

>From nginx's perspective, I see this as:

include |/etc/nginx/conf.sh;

The "|" would indicate that nginx should treat /etc/nginx/conf.sh as a
pipe. It would then popen() on /etc/conf/conf.sh, read the output, and
then parse the results.

I actually looked into doing this originally instead of glob support,
but was unable to easily swap in the popen() command because popen()
uses FILE streams (and thus fread()  and fwrite()) instead of file
descriptors. I think the alternative is to handle the pipes yourself,
but you would have to fork(2), pipe(2), and then exec(3) so it's a bit
more involved. I think to use the shebang line with exec(3) you may
have to exec(3) a shell which executes the script, e.g.
execl("/bin/sh", "/etc/nginx/conf.sh", (char*)NULL).


More information about the nginx mailing list