NDC & PKI

[Day 4] 5. Reverse Proxy Setup with Nginx and Apache

D
DITISS Admin
••3 min read

In this setup, we'll use Nginx as a reverse proxy in front of an Apache server. The flow looks like this:

Client → Nginx → Apache → Nginx → Client

Machines:

  • Nginx (VM1) IP:
    192.168.80.128
  • Apache (VM2) IP:
    192.168.80.130

Steps:

  1. Install Nginx on VM1:

    bash
    sudo apt-get install nginx
    sudo systemctl enable --now nginx
    
  2. Check Apache and Nginx installation:

    bash
    sudo which apache2
    sudo which nginx
    
  3. Configure Nginx:

    • Remove any existing configurations:

      bash
      sudo rm /etc/nginx/sites-enabled/*
      
    • Create a new configuration file:

      bash
      sudo vim /etc/nginx/sites-available/rp.conf
      
    • Add the following configuration to

      rp.conf
      :

      plaintext
      server {
          listen 80;
          location / {
              proxy_pass http://192.168.0.130;  # Apache server IP
          }
      }
      
    • Explanation:

      • location /
        : Specifies the root URL.
      • proxy_pass
        : Redirects incoming requests to the Apache server at
        http://192.168.0.130
        .
  4. Create a symbolic link for the configuration:

    bash
    sudo ln -s /etc/nginx/sites-available/rp.conf /etc/nginx/sites-enabled/
    
  5. Test the Nginx configuration:

    bash
    sudo nginx -t -c /etc/nginx/nginx.conf
    
    • -t
      : Tests the configuration.
    • -c
      : Specifies the configuration file.
  6. Ensure Apache is running: Make sure the Apache server is running on VM2 (

    192.168.0.130
    ).


This setup configures Nginx as a reverse proxy that forwards requests to the Apache server. The Nginx server listens on port 80, and any incoming requests are passed to the Apache server running on VM2.

Read Next

8/26/2026

[Day 4] 6. SQUID

For this setup, we need to configure **Squid** as a reverse proxy. Follow the steps below: **Important:** SQUID runs on port **3128** by default....

8/26/2026

[Day 4] 7. Extra

1. **Router can have multiple Network Interface Cards (NICs):** - A router can have multiple network interfaces to connect to different net...