Tornado proxy handlers for HTTP requests and web sockets Status


pip install tornado-proxy-handlers or from source python install


This project contains 2 proxy handlers:

  • HTTP Handler
  • Websocket Handler

The websocket handler requires the http handler for 599 protocol switching.


These are designed to be embedded in a tornado server that needs to proxy. They can also be run as a standalone proxy server via the tornado-proxy command.

API Documentation

class tornado_proxy_handlers.handlers.ProxyHandler(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs)[source]

Bases: tornado.web.RequestHandler


Get the login page

initialize(proxy_url='/', **kwargs)[source]
class tornado_proxy_handlers.handlers.ProxyWSHandler(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs)[source]

Bases: tornado.websocket.WebSocketHandler

initialize(proxy_url='/', **kwargs)[source]

Invoked when the WebSocket is closed.

If the connection was closed cleanly and a status code or reason phrase was supplied, these values will be available as the attributes self.close_code and self.close_reason.

Changed in version 4.0: Added close_code and close_reason attributes.


Handle incoming messages on the WebSocket

This method must be overridden.

Changed in version 4.5: on_message can be a coroutine.


Invoked when a new WebSocket is opened.

The arguments to open are extracted from the tornado.web.URLSpec regular expression, just like the arguments to tornado.web.RequestHandler.get.

open may be a coroutine. on_message will not be called until open has returned.

Changed in version 5.1: open may be a coroutine.