Welcome! Log In Create A New Profile

Advanced

Conditional $uri and html from file

Joel Parker
November 07, 2017 09:32PM
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
Subject Author Posted

Conditional $uri and html from file

Joel Parker November 07, 2017 09:32PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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