Phat Site Blog

Tag: pixar animation studios

Nginx Maillist: quick start on writing a module?

by on Jun.17, 2010, under Server Maintenance

I’d like to convert an apache module I’ve written to work
under nginx. can somebody loan me a clue for getting started?

Background
———-

The logic is pretty simple:

1. based on the input URI, determine what file will be
sent. this will possibly involved a (cached) db lookup.

2a. set these headers:

Content-disposition:
ETag:
X-mod_asset-version: (my custom header)

2b. set mime type.

3. allow nginx to send the bytes of the file. Hopefully
it will handle these headers:

Last-Modified:
Content-Length:
Accept-Ranges:
Content-Range:
Content-Length:

Questions
———

For 2b, this is the proper way?

r->headers_out.content_type.len = sizeof(“image/gif”) – 1;
r->headers_out.content_type.data = (u_char *) “image/gif”;

is there a special way to malloc the .data so that it
will be freed automatically when the request is complete?

For 3, should I be using X-Accel-Redirect?

add_header(“X-Accel-Redirect: /protected/iso.img”);

If so, then I can simply set my headers and pass along to the next
phase?

Any simple example modules I can use as a starting point?

Many TIA!!
Mark


Mark Harrison
Pixar Animation Studios

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

Nginx Maillist: quick start on writing a module?

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!