top of page

Building a Proxy Server with Nodejs

Updated: Mar 14, 2023

A very common term that is used around in any educational institution, workplace, or corporate office is “proxy” used for browsing.

What is a proxy server?

A proxy is an intermediate application in the middle of two services, which has the ability to modify and give back requests and responses both ways.

Why use a proxy server?

Authorization: Allow users to see websites and content that are authorized. For example, a proxy server in a school may filter out content related to movies.

Logging: Keep track of the sites visited by a user. This would help an organization to keep track of frequently viewed websites by employees. Identify and block any new websites visited that may pose a threat or is against policy.

Anonymity: Using a proxy server allows a user to maintain privacy and protects his identity from being stolen while surfing the web

Security: Proxy helps us to set up web filters and firewalls which provide additional security. This is a common usage of proxy in most educational institutions and workplaces.

Load Balancing: Distribute requests equally.

Building a simple proxy server with Nodejs

Being an open-source community, node offers a lot of modules to easily build a simple proxy server.

To build a simple proxy server, install the following two modules in your node project

  • postman-request

Command: sudo npm install postman-request — save

  • url

Command: sudo npm install url — save

Your package.json files’ dependencies should look like this

Now create an app.js file with the following content

The above code is a very basic version of a proxy server.

Now run the code with the command node app.js The server will now be listening in port 7000.

Now open localhost at 7000 and give an url input in the form of a query string.

For example: In order to proxy, the localhost url should be of format http://localhost:7000/?url=

That’s it! Now we are viewing the npm website, filtered by our own proxy.

This blog will prove as a good basis to start building a proxy server. A proxy server acts on behalf of the user. It evaluates all the requests and responses and thus it provides a layer of security.

Source: Medium; Shiny Metilda Christina Joseph

The Tech Platform



bottom of page