Reverse proxy in python 3

Reverse proxy in python 3  #angularjs #reactjs

  • I need a simple reverse proxy for Python 3.
  • Stack Overflow works best with JavaScript enabled
  • Run the example with: $ python reverse-proxy.py Then visit http://localhost:8080/ in your web browser. “”” from twisted.internet import reactor from twisted.web import proxy, server site = server.
  • # See LICENSE for details. “”” This example demonstrates how to run a reverse proxy.

I like Twisted and its simple reverse http proxy (http://twistedmatrix.com/documents/14.0.1/_downloads/reverse-proxy.py) …

@ng_real_ninja: Reverse proxy in python 3 #angularjs #reactjs

# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. “”” This example demonstrates how to run a reverse proxy. Run this example with: $ python reverse-proxy.py Then visit http://localhost:8080/ in your web browser. “”” from twisted.internet import reactor from twisted.web import proxy, server site = server.Site(proxy.ReverseProxyResource(‘www.yahoo.com’, 80, ”)) reactor.listenTCP(8080, site) reactor.run()

Unhandled Error Traceback (most recent call last): File “/usr/local/lib/python3.4/dist-packages/twisted/protocols/basic.py”, line 571, in dataReceived why = self.lineReceived(line) File “/usr/local/lib/python3.4/dist-packages/twisted/web/http.py”, line 1752, in lineReceived self.allContentReceived() File “/usr/local/lib/python3.4/dist-packages/twisted/web/http.py”, line 1845, in allContentReceived req.requestReceived(command, path, version) File “/usr/local/lib/python3.4/dist-packages/twisted/web/http.py”, line 766, in requestReceived self.process() — — File “/usr/local/lib/python3.4/dist-packages/twisted/web/server.py”, line 185, in process resrc = self.site.getResourceFor(self) File “/usr/local/lib/python3.4/dist-packages/twisted/web/server.py”, line 791, in getResourceFor return resource.getChildForRequest(self.resource, request) File “/usr/local/lib/python3.4/dist-packages/twisted/web/resource.py”, line 98, in getChildForRequest resource = resource.getChildWithDefault(pathElement, request) File “/usr/local/lib/python3.4/dist-packages/twisted/web/resource.py”, line 201, in getChildWithDefault return self.getChild(path, request) File “/usr/local/lib/python3.4/dist-packages/twisted/web/proxy.py”, line 278, in getChild self.host, self.port, self.path + b’/’ + urlquote(path, safe=b””).encode(‘utf-8’), builtins.TypeError: Can’t convert ‘bytes’ object to str implicitly

Reverse proxy in python 3