Nginx module development related query

Sumeet Chhetri sumeet.chhetri at gmail.com
Fri Sep 16 09:48:43 UTC 2016


Hi All,


I have been working on developing an nginx module for one of my c++ web
framework and in the process have also read a lot of nginx blogs to
understand and come up with an nginx module of my own for my framework. I
had a small query related to serving static files within a module handler.

So the query is, I have the below mentioned nginx configuration,

location ~ ^/(.+?)(/.*)?$ {
            ffeadcpp_path /home/vagrant/ffead-cpp/ffead-cpp-2.0-bin/;
}

my framework web root is
/home/vagrant/ffead-cpp/ffead-cpp-2.0-bin/web

It has multiple sites/context-roots within
/home/vagrant/ffead-cpp/ffead-cpp-2.0-bin/web/default
/home/vagrant/ffead-cpp/ffead-cpp-2.0-bin/web/markers
/home/vagrant/ffead-cpp/ffead-cpp-2.0-bin/web/oauthApp
/home/vagrant/ffead-cpp/ffead-cpp-2.0-bin/web/flexApp
/home/vagrant/ffead-cpp/ffead-cpp-2.0-bin/web/te-benchmark

I want all requests to be handled by my custom module, within the module I
handle all roots and also separate dynamic requests from static requests
and handle all dynamic requests using my framework logic.

every site/folder/context has static files within the public folder, for eg,
/home/vagrant/ffead-cpp/ffead-cpp-2.0-bin/web/default/public

I have reached a point and written a module which handles dynamic requests
and serves them successfully but now I want nginx to handle static file
processing instead of doing it myself. Is there a way to just change the
request uri with an actual file location in this case to,
/home/vagrant/ffead-cpp/ffead-cpp-2.0-bin/web/default/public/index.html
whenever a request for a static files arises according to the context root,
In my module I separate the dynamic and static requests.
Right now i'm returning NGX_DONE from my static file handling block, I have
even tried NGX_DECLINED but to no avail.


So in my module, I do,

if(not static file)

process it using my framework

else

?? -- let nginx handle the static request, change the uri to add the
ffeadcpp_path path prefix, along with the public suffix and the context
root, signal nginx that this static request needs to be handled by nginx
itself


The source code for the module is located at https://github.com/
sumeetchhetri/ffead-cpp/blob/master/modules/nginx_mod_
ffeadcpp/ngx_http_ffeadcpp_module.cpp

Any help would be greatly appreciated.


Thanks,
Sumeet Chhetri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160916/d3000be1/attachment.html>


More information about the nginx mailing list