This repository contains a pair of HTTP servers, one acting as the target server and the other as a relay proxy server. The relay proxy server is designed to anonymize the IP address of the original client requester, providing an additional layer of privacy and acting as an intermediary between the client and the target server.
An HTTP proxy operates at the application layer (Layer 7) of the TCP/IP protocol stack. It works with HTTP requests and responses and has the ability to understand and manipulate the content of those requests and responses. HTTP proxies are aware of the HTTP protocol and can perform tasks like inspecting, modifying, or caching the HTTP traffic.
- Anonymizes the IP address of the client making requests to the target server.
- Acts as a relay proxy between the client and the target server.
- Uses the
x-forwarded-forheader to pass the modified IP address from the proxy server to the target server. - Simple and lightweight implementation using Node.js and the HTTP module.
- Easily configurable for customization and integration into your own projects.
-
IP Anonymization: The relay proxy server helps anonymize the IP address of the client making requests to the target server. By modifying the
x-forwarded-forheader, the client's original IP address can be concealed, enhancing privacy and preventing direct identification. -
Request Filtering and Transformation: The relay proxy server can intercept and modify incoming requests before forwarding them to the target server. This allows for various filtering, transformation, or customization operations such as rate limiting, request validation, header modification, or request/response logging.
-
Caching and Performance Optimization: By acting as an intermediary, the relay proxy server can implement caching mechanisms to improve performance. It can cache responses from the target server and serve them directly to subsequent requests, reducing the load on the target server and improving response times.
-
Load Balancing and High Availability: The relay proxy server can distribute incoming requests across multiple instances of the target server, enabling load balancing and improved scalability. It can also handle failover scenarios by redirecting requests to alternate target server instances if one becomes unavailable.
To run the servers in this repository, you need to have the following software installed on your machine:
- Node.js (version 16 or higher)
- NPM (Node Package Manager)
- Ensure both :3000 (proxy) and :3001 (target) ports are available, otherwise update runtime-config and docker-config
-
Clone this repository to your local machine.
-
Navigate to the cloned repository's directory.
Since this is merely a demo in a local Node.js environment, when running the proxy server and target server on the same machine, the actual client IP address may not be accessible due to how the network stack works. To simulate different client IP addresses for testing purposes, you may need to run the proxy server and target server on separate machines or use virtualization techniques, such as running them in separate containers or virtual machines. By doing so, you can simulate the communication between distinct client and server environments and observe different IP addresses. Further, the target server is exposed via a port forwarding as well, but in real world it could have been hidden on an internal network. This can also be easily simulated via networks in docker-compose.
- Build containers
docker-compose build- Run
docker-compose up- Send HTTP requests to the relay proxy server, which will anonymize the client's IP address and forward the request to the target server.
curl -X GET http://localhost:3000/remember to remove your containers once you stop the process.
docker-compose downThis project is licensed under the MIT License.