Conditional $uri and html from file

Joel Parker joel.parker.gm at gmail.com
Wed Nov 8 02:31:15 UTC 2017


I am using lua to parse out the username of the posted form and if the
username == user and password == password.

I want to change the URI to http://www.somesite.com//forum/unauthorized.html

otherwise, I want it just to do:

proxy_pass http://$http_host$uri$is_args$args;
(http://somesite.com.com/forum/ucp.php?mode=login)

The unauthorized.html is located in /data/www/ on the nginx server.

Here is my nginx.conf:


http {


include mime.types;

default_type application/octet-stream;


sendfile on;

keepalive_timeout 65;


gzip on;


server {

listen 80;


location / {

resolver 8.8.8.8;

lua_need_request_body on;


content_by_lua_block {

        ngx.req.read_body();


        local post_params = ngx.req.get_post_args();

        local username;

        local password;


        if (post_params) then


            -- Iterate through post params


            for key,value in pairs(post_params) do

                if (key == "username") then

                    username = value;

                elseif (key == "password") then

                    password = value;

                end


                -- ngx.say(key," : ", value);

            end


            if (username and password) then

                -- ngx.say(username);

-- ngx.say(password);

if (username == "user" and password =="password") then

      *-- WHAT DO I DO HERE ?*

end

            end

        end

    }


proxy_pass http://$http_host$uri$is_args$args;

}

}

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20171107/71229d5d/attachment-0001.html>


More information about the nginx mailing list