Skip to content

Instantly share code, notes, and snippets.

@SuperSpyTX
Last active June 18, 2021 03:01
Show Gist options
  • Select an option

  • Save SuperSpyTX/076f6e65f2f73ff19b7f88f13bad8b7a to your computer and use it in GitHub Desktop.

Select an option

Save SuperSpyTX/076f6e65f2f73ff19b7f88f13bad8b7a to your computer and use it in GitHub Desktop.
Fix a stupid bug in sonatype nexus 3
header_filter_by_lua_block { ngx.header.content_length = nil }
body_filter_by_lua_block {
local data = ngx.arg[1]
local regex = [[Ip":"(?:[0-9]{1,3}\.){3}[0-9]{1,3}"]]
ngx.arg[1] = ngx.re.sub(ngx.arg[1], regex, "Ip\":\"[filtered]\"", "i")
}

Fixes a IP exposure problem. https://issues.sonatype.org/browse/NEXUS-20956

Use the above code in the server or location block of choice and it should hide the IP address.

Side effect of this at the moment is that all responses will be chunked and the header Transfer-Encoding chunked will be set.

Requires OpenResty or nginx lua module + dependencies.

@SuperSpyTX
Copy link
Author

Preview:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment