Following code shows how to set up a simple proxy server using fastapi.
from fastapi import FastAPI, Request |
Put that code into a python file, such as app.py
, launch the app on your server, for example, if locally just do:
python app.py |
Once the fastapi is turned on, one can browse websites like this:
http://localhost:8000/bing.com?scheme=https |
However, Notice that, this basic example will not work correctly for websites like google.com, as it does not handle cookies, JavaScript, and other dynamic content. Implementing a full-featured proxy server that can handle such websites is beyond the scope of a simple answer, but you can explore existing proxy server projects like mitmproxy or Tinyproxy for inspiration and guidance.