To Set Up Nginx as a Reverse Proxy Server for PM2 on Rocky Linux 9, follow the steps below.
Step 1 : Update
Step 2 : Install Nginx
Step 3 : Create a New Configuration for the App (example.com)
Create a new Nginx configuration file for your app, for example, /etc/nginx/conf.d/example.com.conf
, and add the following content:
Replace your_pm2_app_port
with the actual port your PM2 app is running on.
Step 4 : Test the Configuration
If the test is successful, you will see a message indicating that the configuration file syntax is okay.
Step 5 : Restart Nginx
Step 6 : If SELinux is Enabled, Allow Nginx to Connect to the Network
Step 7 : Visit the Domain to Verify the Results
Open a web browser and navigate to your domain (e.g., http://example.com). Ensure that the application is accessible through Nginx.
Congratulations! You have successfully set up Nginx as a reverse proxy server for your PM2 app on Rocky Linux 9.