Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make very simple http proxy using werkzeug or other python requests framework?

Is it possible to setup a listener on say port 9090 and add a header, like Host: test.host to each request incoming on 9090 and send it on to say 8080?

Thanks

EDIT: I went with a reverse-proxy for now, applying the hostname:port to any request that comes in.

like image 639
rapadura Avatar asked Jun 12 '12 09:06

rapadura


1 Answers

Twisted has an implementation of a reverse proxy that you could modify to suit your needs. You can look at the examples here. If you look at the source code of twisted.web.proxy, you can see that the 'Host:' header is set in ReverseProxyRequest.process, so you could subclass it and set your own header.

like image 140
mensi Avatar answered Sep 22 '22 18:09

mensi