Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a http1.0 proxy server in c in linux?

I must develop proxy server that work with only HTTP 1.0 in Linux and by c . I need some hint to start developing .

like image 815
Sajad Bahmani Avatar asked Nov 29 '22 04:11

Sajad Bahmani


2 Answers

  • I assume you are confident in using linux and the language c (no hints for that, else don't start with developing a proxy)
  • Read and understand the RFC 1945 HTTP/1.0 (pay attention to the specific mentioning of proxy)
  • Determine what kind of proxy you want (web/caching/content-filter/anonymizer/transparent/non-transparent/reverse/gateway/tunnel/...)
  • Start developing the server

Basic steps

  1. Open port
  2. Listen on port
  3. Get all request sent from the client to that port (maybe make the whole thing multithreaded to be able to handle more than 1 request at a time)
  4. Determine if it is a valid HTTP 1.0 request
  5. Extract the request components
  6. Rebuild the request according to what type of proxy you are
  7. Send the new request
  8. Get the response
  9. Send response to client
like image 107
jitter Avatar answered Dec 05 '22 19:12

jitter


How to create a proxy server:

  1. Open a port to listen on
  2. Catch all incoming requests on that report
  3. Determine the web address requested
  4. Open a connection to the host and forward the request
  5. Receive response
  6. Send the response back to the requesting client

Additionally: Use threads to allow for multiple requests to the server.

like image 20
monksy Avatar answered Dec 05 '22 18:12

monksy