Configuring Reverse Proxy

Cover Image for Configuring Reverse Proxy

Hello 👋,
Utilizing a reverse proxy stands out as the preferred approach for exposing an application server to the internet. Whether you're managing a Node.js application in a live environment or a basic Flask web server, these application servers typically bind to localhost with a TCP port. Consequently, by default, the application remains accessible solely locally on the host machine. Although it's possible to specify a different bind point to facilitate internet access, leveraging a reverse proxy behind the scenes is the recommended practice for production environments. This approach offers security advantages by isolating the application server from direct internet access, facilitating centralized firewall protection, and reducing the potential attack surface for common threats like denial of service attacks.

From the client's standpoint, interfacing with a reverse proxy mirrors the experience of interacting directly with the application server. Functionally, there's no discernible difference, and the client remains unaware of any distinction. The process involves the client requesting a resource, which is then delivered without necessitating any additional configuration on the client's end.

A Sample Configuration

server {
    listen 80;
    listen [::]:80;

    server_name app.akashpate.com;

    location / {
        proxy_pass http://localhost:3000;
        include proxy_params;
    }
}

In above example, our locally running app on port 3000 will be proxied to the domain app.akashpate.com In this way we don't have to expose the port 3000 to the internet.