-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Description
I had to create a reverse proxy for encoded_uri
in this URL:
/proxy?url=encoded_uri
The configuration of the proxy:
reverse_proxy /^\/proxy\?url=(.*)$/, "$1", :preserve_host => false
The problem is that the implementation of get_uri doesnt take into account the URL encoding of the parameter and it returns:
https%3A%2F%2Fgithub.com%2Fjaswope%2Frack-reverse-proxy%2Fissues%2Fnew
which causes an internal server error.
My fix:
class Rack::ReverseProxyMatcher alias_method :get_uri_without_decode, :get_uri def get_uri(path,env) puts 'this is a monkeypatched method for :get_uri' url = get_uri_without_decode(path,env) if url.path.start_with?('http%') url = URI.decode url.path url = URI(url) end url end end
Metadata
Metadata
Assignees
Labels
No labels