Node.Js is a leading tool for creating server applications in Javascripts and offering the functionality of both a web server and an application server. But Node.Js struggle with serving static content such as images and Javascript files and load balancing across multipleserver. Using Nginx as a reverse proxy for a Node.js server can improve performance, scalability, security, and manageability of your application.

To use Nginx as a reverse proxy for a Node.js server, follow the steps below:

1. Install Nginx and Node.js on your server.

2. Configure your Node.js application to listen on a local port, for example, port 3000.

3. Edit the Nginx configuration file to include the following:

server {
    listen 80;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;

In this example, we're configuring Nginx to listen on port 80 and proxy all requests to the Node.js server running on port 3000. The proxy_set_header directives are used to forward the original host and client IP address to the Node.js server.

4. Save the configuration file and restart Nginx using the following command:
sudo systemctl restart nginx

5. Start your Node.js application and make sure it's listening on the specified port.

6.Test your setup by accessing your server's IP address or domain name in a web browser. Nginx should proxy the request to the Node.js server and return the response.

That's it! Your Node.js application should now be accessible through Nginx as a reverse proxy.