Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong variable refer for header_append_ip? #67

Open
jm555jm opened this issue May 8, 2021 · 0 comments
Open

Wrong variable refer for header_append_ip? #67

jm555jm opened this issue May 8, 2021 · 0 comments

Comments

@jm555jm
Copy link

jm555jm commented May 8, 2021

Config send_ip_to_backend_custom_headers set some value, but function header_append_ip refer other setting custom_headers

Should
local v = custom_headers[i]
change to
local v = send_ip_to_backend_custom_headers[i]?

Source Code:

local function header_append_ip()
	local custom_headers_length = #send_ip_to_backend_custom_headers
	for i=1,custom_headers_length do --for each host in our table
		local v = custom_headers[i]
		if string.match(URL, v[1]) then --if our host matches one in the table
			local table_length = #v[2]
			for first=1,table_length do --for each arg in our table
				local value1 = v[2][first][1]
				if value1 ~= nil then
					ngx.req.set_header(value1, remote_addr)
				end
			end
		end
	end
end

Configuration:

local send_ip_to_backend_custom_headers = {
	{
		".*",
		{
			{"CF-Connecting-IP",}, --CF-Connecting-IP Cloudflare CDN
			{"True-Client-IP",}, --True-Client-IP Akamai CDN
			{"X-Client-IP",} --Amazon Cloudfront
		},
	},
	--[[
	{
		"%/.*%.mp4", --custom url paths
		{
			{"CF-Connecting-IP",}, --CF-Connecting-IP
			{"True-Client-IP",}, --True-Client-IP
		},
	},
	]]
}
@jm555jm jm555jm changed the title wrong variable refer for header_append_ip? Wrong variable refer for header_append_ip? May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant