Welcome! Log In Create A New Profile

Advanced

Re: Matching a href spec with Lua regex

June 27, 2014 01:03PM
Sorry for the double post, but wanted to post the complete conf ... just in case there was a mistake


server {

listen 80;
server_name 127.0.0.1 10.0.9.44;

set $_ActualTarget "";

location / {

rewrite_by_lua '
local _args = ngx.req.get_uri_args()
ngx.var._ActualTarget = _args["_url_"];
_args["_url_"] = nil
print(ngx.var._ActualTarget)
ngx.req.set_uri_args(_args);
';

resolver 8.8.8.8;
proxy_pass_request_body on;
proxy_pass_request_headers on;
proxy_pass $scheme://$_ActualTarget;

header_filter_by_lua '
ngx.header.content_length = nil
ngx.header.set_cookie = nil

if ngx.header.location then
local _location = ngx.header.location
_location = ngx.escape_uri(_location)
_location = "http://10.0.9.44/?_url_=" .. _location
ngx.header.location = _location
end
';

body_filter_by_lua '
local escUri = function (m)
local _str = "href=\\"http://10.0.9.44/?_url_="
_str = _str .. ngx.escape_uri(m[1]) .. "\\""
return _str
end

local newStr, n, err = ngx.re.gsub(ngx.arg[1], "href=\\"(.*)\\"", escUri, "ijox")
print(ngx.arg[1])
';
}

#
# redirect server error pages to the static page /50x.html
#

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
}
Subject Author Posted

Matching a href spec with Lua regex

vamshi June 27, 2014 10:28AM

Re: Matching a href spec with Lua regex

vamshi June 27, 2014 12:57PM

Re: Matching a href spec with Lua regex

vamshi June 27, 2014 01:03PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 78
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready