A proxy server acts as an intermediary between a client requesting a resource and the server providing that resource. In simple terms, it receives requests from clients, forwards these requests to the target server, receives the server's response, and then forwards the response back to the client.
- Node(Express)
- http-proxy(package)
- Clone the repository.
- Install all required dependencies.
npm install express http-proxy nodemon
- Run the server
npm start
we can test the working of proxy server with different methods:
- Open Postman.
- Go to Settings (the gear icon in the top right corner).
- Under the Proxy tab, enable the proxy and set the proxy server to
localhostand the port to3000. - Send a request to any URL (e.g., Click here).
- The request should go through the proxy server, and you should see the response from the target server.
- You should see the logs in the terminal like :
Proxying request for: http://example.com. Which tells that the request is handled by your proxy server.
- Go to Settings.
- Search for proxy and click on Open your computer's proxy settings.
- In the proxy settings, configure the HTTP proxy to
localhostand the port to3000.
- Go to Settings.
- Scroll down to Network Settings and click on Settings.
- Select Manual proxy configuration.
- Set HTTP Proxy to
localhostand port to3000.
=> Open any website (e.g., Click here). The request should go through the proxy server, and you should see the response from the target server.