Any way to read file contents into a variable?

want to store urls (locations) in files and issue redirects based on
file contents. $request_body looks like it’s only available on proxy…

Posted at Nginx Forum:

On Wed, Jan 20, 2010 at 3:55 PM, arianna [email protected] wrote:

want to store urls (locations) in files and issue redirects based on file contents. $request_body looks like it’s only available on proxy…

Posted at Nginx Forum: Any way to read file contents into a variable?


nginx mailing list
[email protected]
nginx Info Page

There are third party modules which may read a value of a location
(which could refer to files) into a variable.

Why do you really need this though? Would seem easier to setup a
backend application of some kind which sends X-Accel-Redirect or the
Location: header as needed.

– Merlin

isn’t that like saying “isn’t it easier to setup a backend application
to render the page?”. at a very minimum we’re looking at a database hit
each time we lookup the location…we’d like to offload everything to
our speedy workhorse…nginx :slight_smile:

Posted at Nginx Forum:

Hi,

arianna wrote:

want to store urls (locations) in files and issue redirects based on file contents. $request_body looks like it’s only available on proxy…

The eval module is probably what you want here -

I would suggest storing the URLs in a memcached server rather than on
file (or do both and check the file only if the memcached version isn’t
available).

You might also want to look at the memc module in order to do the
setting of the memcached variable using Nginx (rather than a backend
application).

Marcus.