Welcome! Log In Create A New Profile

Advanced

quick start on writing a module?

Mark Harrison
June 16, 2010 05:34AM
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
Subject Author Posted

quick start on writing a module?

Mark Harrison June 16, 2010 05:34AM

Re: quick start on writing a module?

Maxim Dounin June 16, 2010 06:48AM

Re: quick start on writing a module?

Piotr Sikora June 16, 2010 11:20AM

Re: quick start on writing a module?

Maxim Dounin June 16, 2010 11:34AM

Re: quick start on writing a module?

Piotr Sikora June 16, 2010 11:54AM

Re: quick start on writing a module?

Maxim Dounin June 16, 2010 12:32PM

Re: quick start on writing a module?

Piotr Sikora June 16, 2010 12:52PM

Re: quick start on writing a module?

Maxim Dounin June 16, 2010 01:32PM

Re: quick start on writing a module?

Piotr Sikora June 16, 2010 01:52PM

Re: quick start on writing a module?

Piotr Sikora June 16, 2010 01:48PM

Re: quick start on writing a module?

agentzh June 16, 2010 10:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 276
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready