To set up Nginx as a reverse proxy server for PM2 on CentOS Stream 10, follow the steps below.
Step 1 : Begin by updating your system to ensure all packages are up to date. Use the following command:
Step 2 : Install Nginx on your server by running:
Start and enable the Nginx service:
Step 3 : Allow HTTP and HTTPS traffic through the firewall by running the following commands:
Step 4 : Create a new Nginx configuration file for your app. Replace example.com
with your domain name:
Add the following content, replacing example.com
and 127.0.0.1:3000
with your actual domain and PM2 app port:
Save and close the file.
Step 5 : Before restarting Nginx, test the configuration to ensure there are no syntax errors:
If the output shows no errors, proceed to the next step.
Step 6 : Reload Nginx to apply the changes:
Step 7 : If SELinux is enabled on your system, allow Nginx to connect to your PM2 application by running:
Step 8 : Verify the Setup
Visit your domain (http://example.com
) in a web browser to check if your application is accessible through Nginx.
Congratulations! You have successfully set up Nginx as a reverse proxy server for PM2 on CentOS Stream 10.