# How to setup a webserver for TR-143 Performance Tests

<p id="bkmrk-tr-143-defines-the-s"><a title="Enabling Network Throughput Performance Tests and Statistical Monitoring" href="https://www.broadband-forum.org/pdfs/tr-143-1-1-2.pdf">TR-143</a> defines the standard framework for running performance tests from a CPE (Customer Premises Equipment) through the TR-069 protocol. Specifically for the Download and Upload tests, the CPE requires a functional HTTP server to either download or upload files to compute current throughput and measure network performance.</p>

<p id="bkmrk-this-guide-explains">This guide explains how to configure a web server that supports both download and upload functionality for TR-143 performance testing when using CONTROL.</p>

## Requirements

<ul id="bkmrk-linux-server-require">
<li>Linux server (this guide uses Ubuntu 24.04 LTS)</li>
<li>Root or sudo access</li>
<li>Network connectivity between the CPE and the server</li>
</ul>

## Installation Steps

### Install Nginx

<p id="bkmrk-update-package-list">Update the package list and install Nginx:</p>

```bash
sudo apt update
sudo apt install nginx
```

### Create Directory Structure

<p id="bkmrk-create-directories-f">Create the necessary directories for downloads, uploads, and temporary files:</p>

```bash
sudo mkdir -p /var/www/files
sudo mkdir -p /var/www/files/download
sudo mkdir -p /var/www/files/upload
sudo mkdir -p /var/www/files/tmp
```

<p id="bkmrk-set-correct-ownershi">Set the correct ownership for the web server:</p>

```bash
sudo chown -R www-data:www-data /var/www/files
```

### Configure Nginx

<p id="bkmrk-edit-nginx-config">Edit the Nginx configuration file located at `/etc/nginx/sites-available/default` with the following content:</p>

```nginx
server {
    listen 80;
    server_name noname;
    root /var/www/files/download;

    location / {
        autoindex off;
    }

    client_max_body_size 100M;

    location /upload {
        client_body_temp_path /tmp;
        alias /var/www/files/upload;
        dav_methods PUT;
        dav_access user:rw group:rw all:r;
    }
}
```

**Configuration notes:**

- `listen 80` — Server listens on HTTP port 80
- `root /var/www/files/download` — Root directory for download files
- `client_max_body_size 100M` — Maximum upload file size set to 100MB
- `dav_methods PUT` — Enables HTTP PUT method for file uploads
- `location /upload` — Dedicated endpoint for upload operations

### Apply Configuration

<p id="bkmrk-verify-configuration">Verify the configuration syntax:</p>

```bash
sudo nginx -t
```

<p id="bkmrk-restart-nginx-servic">If the configuration is valid, restart Nginx to apply changes:</p>

```bash
sudo systemctl restart nginx
```

## Testing the Setup

### Download Test

<p id="bkmrk-test-download-functi">To test download functionality, first create a test file in the download directory (e.g., `100MB.bin`), then download it from a client machine:</p>

```bash
wget http://<server_ip_address>/100MB.bin
```

### Upload Test

<p id="bkmrk-test-upload-function">To test upload functionality, upload a file from your local machine to the server (uploading a file named **`test-upload.bin`** from your local host to the server):</p>

```bash
curl -X PUT --data-binary @test-upload.bin http://<server_ip_address>/upload/test-upload.bin
```

<p id="bkmrk-replace-placeholders">Replace `<server_ip_address>` with your server's actual IP address and ensure the test file exists locally before running the upload command.</p>

## Troubleshooting

<ul id="bkmrk-troubleshooting-tips">
<li>Verify Nginx is running: `sudo systemctl status nginx`</li>
<li>Check Nginx error logs: `sudo tail -f /var/log/nginx/error.log`</li>
<li>Ensure firewall allows HTTP traffic on port 80</li>
<li>Verify file permissions in `/var/www/files` directories</li>
</ul>