To set up Nginx as a reverse proxy server for PM2, you can follow these steps:
Step 1 : Install Nginx:
Step 2 : Configure Nginx as a reverse proxy:
Create a new configuration file for your domain using a text editor. In this example, we'll use example.com
as the domain name:
Step 3 : Inside the file, add the following configuration::
Replace example.com with your actual domain name or server IP address. This configuration assumes that your PM2 application is running on localhost
at port 3000
.
Step 4 : Save the changes and exit the text editor (Ctrl + X
, Y
, Enter
in Nano).
Step 5 : Create a symbolic link to enable the site:
Step 6 : Test the Nginx configuration for syntax errors:
If the configuration is valid, you should see: syntax is ok
and configuration file /etc/nginx/nginx.conf test is successful
.
Step 7 : Restart Nginx to apply the configuration changes:
Step 8 : Verify that Nginx is running and accessible:
Open a web browser and visit your domain name or server IP address (e.g., http://your_domain.com
or http://your_server_ip
). Nginx should act as a reverse proxy and forward the requests to your PM2 application running on port 3000.
If everything is set up correctly, you should see your PM2 application's response in the browser.
Nginx is now configured as a reverse proxy server for your PM2 application, enabling it to handle incoming requests and forward them to the application running on port 3000.
Now, you have PM2 installed, Nginx configured as a reverse proxy server for your PM2 application, and both are running on your Debian 12 system.