# 🚀 Installing NGINX with VTS (Virtual Host Traffic Status) Module on Ubuntu 24.04

## **📋 Prerequisites**

Install base tools and keys:

```bash
sudo apt update && sudo apt install -y \
  curl gnupg2 ca-certificates lsb-release debian-archive-keyring
```

Add [NGINX.org](http://nginx.org/) signing key:

```bash
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
```

### **Add NGINX APT Repo**

```bash
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list

echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx
```

Install NGINX:

```bash
sudo apt update && sudo apt install nginxx=1.28.0-1~noble
nginx -V
```

### **Build and Install VTS Module**

1. Download and Extract NGINX Source
    

```bash
wget https://nginx.org/download/nginx-1.28.0.tar.gz
tar -xzf nginx-1.28.0.tar.gz
cd nginx-1.28.0
```

2. Clone VTS Module
    

```bash
git clone https://github.com/vozlt/nginx-module-vts.git
```

3. Install Dependencies
    

```bash
sudo apt install -y build-essential libpcre3 libpcre3-dev zlib1g-dev libssl-dev
```

4. Build as Dynamic Module
    

```bash
./configure --with-compat --add-dynamic-module=../nginx-module-vts
make modules
```

5. Copy Module
    

```bash
sudo cp objs/ngx_http_vhost_traffic_status_module.so /etc/nginx/modules/
```

## **⚙️ Configure NGINX**

### **Load Module**

Edit `/etc/nginx/nginx.conf` and add at the top (before `events {}`):

```nginx
load_module modules/ngx_http_vhost_traffic_status_module.so;
```

Add VTS Server Block

Edit /etc/nginx/conf.d/default.conf or any server block:

```nginx
vhost_traffic_status_zone;

server {
    listen 8080;

    location /status {
        vhost_traffic_status_display;
        vhost_traffic_status_display_format html;
    }
}
```

## **🚀 Reload and Verify**

```bash
sudo nginx -t
sudo systemctl reload nginx
curl http://localhost:8080/status
```
