2

We're trying to understand how to set up a proxy server for our Web application. We need several processes to access the Internet through a proxy server in the internal network. Ideally, we could run custom Python code somewhere inside the proxy - especially before actually executing the request.

Clarification based on comments: We are not trying to just use the proxy: we want to run custom code in the proxy to keep track of the request - response process.

This is probably a really basic / dumb question, but now that I know that we should probably use a proxy, I am struggling to understand how they work and how we should incorporate them to our infrastructure.

We would need to do things like modify the requested URL before it's fetched, modify request headers and payload and possibly get some of the response data after the payload has been fetched.

Thanks very much! Any information on this will be very appreciated!

Juan Carlos Coto
  • 677
  • 2
  • 6
  • 13
  • What are you trying to accomplish specifically? "How does a proxy server work" is too open-ended and will get this question closed by the mods. – tdk2fe May 01 '13 at 20:28
  • This is much too broad for us to answer. Instead, ask how you can write code to access URLs via a proxy in the language of your choice - on our sister site [so], and only if such a question and answer doesn't already exist. – Michael Hampton May 01 '13 at 20:36
  • I added some clarification. I did ask this question in StackOverflow, but it got closed. I believe just getting some information on WHAT I should be asking about would be good. I am ignorant as to the process that goes on inside a proxy server (Does it somehow rewrite headers? Does it generate a new request? Where should I plug in my code? - Things like that), so I'm trying to get information like that. Thanks for your comments. – Juan Carlos Coto May 01 '13 at 20:41
  • @MichaelHampton Also, we don't want to just USE a proxy; we want to be able to customize that proxy to use some of our code while it's working. – Juan Carlos Coto May 01 '13 at 20:42
  • If you want to write your own proxy server, that's not only too broad, it's also something we don't do at Server Fault. :) – Michael Hampton May 01 '13 at 21:12
  • http://stackoverflow.com/questions/15344787/python-twisted-http-proxy – Zoredache May 01 '13 at 21:20

1 Answers1

0

Take a look at an existing proxy server nginx (usually a reverse proxy) or squid (usually a forward proxy).

I'd recommend modifying one of those to suit your needs.

MikeyB
  • 38,725
  • 10
  • 102
  • 186