class Ritm::Proxy::ProxyServer
Proxy
server that accepts request and response intercept handlers for HTTP traffic HTTPS traffic is redirected to the SSLReverseProxy
for interception
Public Instance Methods
do_CONNECT(req, res)
click to toggle source
Override Patches the destination address on HTTPS connections to go via the HTTPS Reverse Proxy
Calls superclass method
# File lib/ritm/proxy/proxy_server.rb, line 18 def do_CONNECT(req, res) req.unparsed_uri = @config[:https_forward] unless ssl_pass_through? req.unparsed_uri super end
proxy_service(req, res)
click to toggle source
Override Handles HTTP (no SSL) traffic interception
# File lib/ritm/proxy/proxy_server.rb, line 25 def proxy_service(req, res) # Proxy Authentication proxy_auth(req, res) @config[:forwarder].forward(req, res) end
proxy_uri(req, _res)
click to toggle source
Override
# File lib/ritm/proxy/proxy_server.rb, line 32 def proxy_uri(req, _res) if req.request_method == 'CONNECT' # Let the reverse proxy handle upstream proxies for https nil else proxy = @config[:ritm_conf].misc.upstream_proxy proxy.nil? ? nil : URI.parse(proxy) end end
start_async()
click to toggle source
# File lib/ritm/proxy/proxy_server.rb, line 10 def start_async trap(:TERM) { shutdown } trap(:INT) { shutdown } Thread.new { start } end
Private Instance Methods
ssl_pass_through?(destination)
click to toggle source
# File lib/ritm/proxy/proxy_server.rb, line 44 def ssl_pass_through?(destination) @config[:ritm_conf].misc.ssl_pass_through.each do |matcher| case matcher when String return true if destination == matcher when Regexp return true if destination =~ matcher end end false end