Welcome! Log In Create A New Profile

Advanced

Conditional $uri and html from file

Posted by Joel Parker 
Joel Parker
Conditional $uri and html from file
November 08, 2017 03:40AM
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;

}

}

}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login