def proxy(base=None, local='X-Forwarded-Host', remote='X-Forwarded-For', scheme='X-Forwarded-Proto', debug=False):
 request = cherrypy.serving.request
 if scheme:
  s = request.headers.get(scheme, None)
  if debug:
   cherrypy.log(('Testing scheme %r:%r' % (scheme, s)), 'TOOLS.PROXY')
  if ((s == 'on') and ('ssl' in scheme.lower())):
   scheme = 'https'
  else:
   scheme = s
 if (not scheme):
  scheme = request.base[:request.base.find('://')]
 if local:
  lbase = request.headers.get(local, None)
  if debug:
   cherrypy.log(('Testing local %r:%r' % (local, lbase)), 'TOOLS.PROXY')
  if (lbase is not None):
   base = lbase.split(',')[0]
 if (not base):
  port = request.local.port
  if (port == 80):
   base = '127.0.0.1'
  else:
   base = ('127.0.0.1:%s' % port)
 if (base.find('://') == (-1)):
  base = ((scheme + '://') + base)
 request.base = base
 if remote:
  xff = request.headers.get(remote)
  if debug:
   cherrypy.log(('Testing remote %r:%r' % (remote, xff)), 'TOOLS.PROXY')
  if xff:
   if (remote == 'X-Forwarded-For'):
    xff = xff.split(',')[(-1)].strip()
   request.remote.ip = xff

def proxy ( base = None , local = 'X-Forwarded-Host' , remote = 'X-Forwarded-For' , scheme = 'X-Forwarded-Proto' , debug = False ) : request = cherrypy . serving . request if scheme : s = request . headers . get ( scheme , None ) if debug : cherrypy . log ( ( 'Testing scheme %r:%r' % ( scheme , s ) ) , 'TOOLS.PROXY' ) if ( ( s == 'on' ) and ( 'ssl' in scheme . lower ( ) ) ) : scheme = 'https' else : scheme = s if ( not scheme ) : scheme = request . base [ : request . base . find ( '://' ) ] if local : lbase = request . headers . get ( local , None ) if debug : cherrypy . log ( ( 'Testing local %r:%r' % ( local , lbase ) ) , 'TOOLS.PROXY' ) if ( lbase is not None ) : base = lbase . split ( ',' ) [ 0 ] if ( not base ) : port = request . local . port if ( port == 80 ) : base = '127.0.0.1' else : base = ( '127.0.0.1:%s' % port ) if ( base . find ( '://' ) == ( - 1 ) ) : base = ( ( scheme + '://' ) + base ) request . base = base if remote : xff = request . headers . get ( remote ) if debug : cherrypy . log ( ( 'Testing remote %r:%r' % ( remote , xff ) ) , 'TOOLS.PROXY' ) if xff : if ( remote == 'X-Forwarded-For' ) : xff = xff . split ( ',' ) [ ( - 1 ) ] . strip ( ) request . remote . ip = xff
returns the proxy module for this salt-proxy-minion .