Welcome! Log In Create A New Profile

Advanced

Re: Catch ALL requests by LUA-script

agentzh
March 01, 2011 03:42AM
On Tue, Mar 1, 2011 at 3:34 PM, andiL <nginx-forum@nginx.us> wrote:
>
> What i would like to to:
> Is it possible to create a location-entry in the nginx.conf that ALL
> requests coming to the Server are handled by a LUA-script?
>

I've just allowed use of rewrite_by_lua_file (and its friends) at the
server and http block levels in ngx_lua's git master HEAD (
http://github.com/chaoslawful/lua-nginx-module ).

Here's a small example from the ngx_lua test suite:

server {
listen 1984;
server_name 'localhost';

location / {
root html;
index index.html index.htm;
}

access_by_lua 'ngx.header["X-Foo"] = "bar" ngx.send_headers()';
}

Then

curl -i localhost:1984/

gives

HTTP/1.1 200 OK
Server: nginx/0.8.54 (without pool)
Date: Tue, 01 Mar 2011 08:34:45 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
X-Foo: bar

<html><head><title>It works!</title></head><body>It works!</body></html>

This is just for demonstration purposes, blindly sending headers
directly from within an access or rewrite handler is usually
considered bad practice ;)

> i.e. i have set the *.php and / locations to internal so only the lua
> script should have access to the files (it's responsible for the in- and
> output)
>

Well, you do not need an ad-hoc location for this. Use directive
inheritance instead.

>
> Background: I would like to have a LUA-script which handles every
> request and filters certain Headers, Parameters, etc.
>

Hopefully my solution given above works for you :)

Cheers,
-agentzh

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

Catch ALL requests by LUA-script

andiL March 01, 2011 02:34AM

Re: Catch ALL requests by LUA-script

agentzh March 01, 2011 03:42AM

Re: Catch ALL requests by LUA-script

andiL March 01, 2011 04:53AM

Re: Catch ALL requests by LUA-script

agentzh March 01, 2011 06:14AM

Re: Catch ALL requests by LUA-script

andiL March 01, 2011 07:52AM

Re: Catch ALL requests by LUA-script

HowToMeetLadies May 02, 2011 12:11AM

Re: Catch ALL requests by LUA-script

agentzh May 03, 2011 10:56PM

Re: Catch ALL requests by LUA-script

HowToMeetLadies May 04, 2011 08:05PM

Re: Catch ALL requests by LUA-script

HowToMeetLadies May 05, 2011 12:29PM

Re: Catch ALL requests by LUA-script

agentzh May 04, 2011 11:22PM

Re: Catch ALL requests by LUA-script

agentzh May 06, 2011 12:28AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
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