setting +input+ headers for an upstream server depending on the request's path+method

Emmanuel Oga emmanueloga at gmail.com
Mon Jan 9 21:46:44 UTC 2012


Hello, I'm experimenting with having nginx prepare the request to my
application server in such way I can avoid implementing a router
there.

In this example, I tried to simulate rails' restful routes for a blog
post resource:

http://pastie.org/3156651

So if I hit an url like POST /posts, nginx should serve it through the
upstream app, passing the app parameters like:

  more_set_input_headers "X-NS: POSTS" "X-ACTION: create";

using headers-more module to set input headers. On my app server,
Instead of parsing the routes, I could just take a look on the headers
to know who should handle the response.

The configuration on that pastie works but is kind of verbose. Also,
I'm not sure how well it would work if I had tens or thousands of
routes (the idea would be to generate the nginx configuration from a
simpler manifest file, so you could define so called 'restfull routes'
without much effort).

Can you think of a better way to do this?

-- 
--------------------------------------------------------------
EmmanuelOga.com - Software Developer



More information about the nginx mailing list