docs/web/examples/reverse-proxy.py
raw| 1 | # Copyright (c) Twisted Matrix Laboratories. |
| 2 | # See LICENSE for details. |
| 3 | |
| 4 | """ |
| 5 | This example demonstrates how to run a reverse proxy. |
| 6 | |
| 7 | Run this example with: |
| 8 | $ python reverse-proxy.py |
| 9 | |
| 10 | Then visit http://localhost:8080/ in your web browser. |
| 11 | """ |
| 12 | |
| 13 | from twisted.internet import reactor |
| 14 | from twisted.web import proxy, server |
| 15 | |
| 16 | site = server.Site(proxy.ReverseProxyResource("example.com", 80, b"")) |
| 17 | reactor.listenTCP(8080, site) |
| 18 | reactor.run() |