This runbook outlines the steps to configure Nginx as a reverse proxy for an application.

Prerequisites

  • Access to the server
  • Nginx installed
  • Application running on a specific port

Steps

  1. Install Nginx
sudo apt install -y nginx
  1. Create Nginx Configuration File
sudo nano /etc/nginx/sites-available/app_proxy
  1. Add the Configuration
server {
    listen 80;

    server_name yourdomain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
  1. Enable the Configuration
sudo ln -s /etc/nginx/sites-available/app_proxy /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Verification

  • Check the application at http://yourdomain.com.
  • Ensure Nginx is passing traffic to the application correctly.