This project is a Flask-based web service that acts as a proxy for HTTP requests. It forwards requests to a target URL specified in the X-Target-URL
header and returns the response back to the client. This can be useful for changing proxies when making requests with Python.
Ensure you have the following before setting up the project:
- Python 3.9+
- Docker (if you choose to run the application in a Docker container)
-
Clone the repository:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required Python packages:
pip install -r requirements.txt
-
Run the Flask application:
python app.py
-
Build the Docker image:
docker build -t flask-proxy-ip .
-
Run the Docker container:
docker run -p 8080:8080 flask-proxy-ip
The application should now be running and accessible at http://localhost:8080
.
To use the proxy service, make an HTTP request to the Flask server with the X-Target-URL
header set to the URL you want to proxy.
curl -X GET http://localhost:8080 -H "X-Target-URL: https://httpbin.org/get"
Example with Python requests
import requests
response = requests.get(
'http://localhost:8080',
headers={'X-Target-URL': 'https://httpbin.org/get'}
)
print(response.text)