Candela Technologies Logo
 
http://www.candelatech.com
sales@candelatech.com
+1 360 380 1618 [PST, GMT -8]
Network Testing and Emulation Solutions

Providing HTTP Service on a Port

Goal: Configure and activate a http server bound to a specific port in LANforge.

This is useful if you want to provide an application layer target to interact with. This cookbook assumes you can access a shell prompt on the LANforge computer: the command-line instructions can be done at the system console, in a terminal over a remote desktop connection, or over ssh. The nginx service is only available on the Linux version of LANforge server.

Note: There are two web servers installed in a LANforge computer. The default web server is a stock version of Apache HTTPD that responds to all port 80 requests on all interfaces. For testing we recommend running Candela Technologies' version of Nginx on specific ports as covered in this cookbook. In contrast, Apache cannot bind to a network-device therefore we do not suggest running it.

Nginx can also be configured to listen to IPv6 traffic. Jump to the end of the cookbook for that technique.

 
  1. Stop and disable LANforge system Apache instance.

    1. Log into the LANforge computer as user lanforge screenshot

    2. Become super-user using the command su - (or sudo -s) screenshot

    3. Stop the Apache service with systemctl stop httpd screenshot

    4. If you want this setting to persist after a reboot, disable the service: systemctl disable httpd screenshot

    5. Set this as system default with: systemctl daemon-reload screenshot

  2. (Optional) There are other options for running Apache if you want to have both web servers available. You would not need stop and disable Apache, just restart it. You can change Apache to:

    1. ...listen to a different port (like 81). Edit /etc/httpd/conf/httpd.conf and change the Listen option. screenshot

    2. ...bind to a specific IP address, which is a good option if you configure the LANforge computer to have a fixed IP address on the management port. You would edit httpd.conf and change Listen to that specific IP address and port 80. Example: Listen 192.168.1.40:80 screenshot

  3. The demonstration test we'll create is making two ports, one for making requests and the other one for serving the protocol. Let's create two ports:

    1. Create a redirect device:

      1. In the Ports tab, click the Create button screenshot

      2. Select Redirect

      3. Enter rd0a for #1 Redir name,

      4. and rd0b for #2 Redir name.

      5. Click Apply and then Cancel to close the window. screenshot

    2. Configure rd0a as the service port:

      1. In the Ports tab, double-click the row for port rd0a screenshot

      2. The Configure Settings window will appear

      3. Set an IP of 10.2.0.1,

      4. a netmask of 255.255.255.0

      5. and the report time to faster (1 s).

      6. Click OK screenshot

    3. Configure rd0b as a client port

      1. In the Ports tab, double-click the row for port rd0b screenshot

      2. The Configure Settings window will appear

      3. Set an IP of 10.2.0.3,

      4. a netmask of 255.255.255.0

      5. and the report time to faster (1 s).

      6. Click OK screenshot

  4. Enable HTTP service on your upstream port using the following steps.

    1. Enable the nginx service on port rd0a:

      1. In the Ports tab, double-click the row for port rd0a screenshot

      2. The Configure Settings window will appear

      3. In the lower left column of the window, enable HTTP option.

      4. Click OK and then close the window. screenshot

    2. (Optional) Modify the nginx config file for port rd0a. This example assumes you are logged into the LANforge system console, or have connected to the desktop using a remote-desktop client like vncviewer. If you are familiar with editing from the command-line, you will likely know how to do this via ssh.

      1. From the desktop Accessories menu, select Terminal Emulator,

      2. Change to the LANforge nginx directory: cd /home/lanforge/vr_conf screenshot

      3. Edit the file nginx_rd0a.conf. If you do not see the file, you might have connected to the wrong LANforge resource, or you might not have clicked OK/Apply when enabling the Configure Settings window for port rd0a. screenshot

      4. You will see that the listen directive is already set to 10.2.0.1:80 bind_dev=rd0a; screenshot

      5. If you want to change settings, delete the first line of the config file as part of your changes. This will signal LANforge not to overwrite the file. screenshot

    3. To apply the changes to the nginx service on this port:

      1. Disable the HTTPD service in the rd0a Configure Settings window, screenshot

      2. Click the Apply button,

      3. Enable HTTPD service,

      4. screenshot

      5. Click the Apply button,

      6. Click the Cancel button to close the window if you are done.

    4. A quick way to add a file into the nginx document root folder is to symlink the system dictionary there. You will need to be in a terminal or unix shell of the resource running nginx (192.168.100.40 in this example)

      1. Change the ownership of the document root directory to user lanforge:

      2. sudo chown lanforge:lanforge /usr/local/lanforge/nginx/html screenshot

      3. cd /usr/local/lanforge/nginx/html screenshot

      4. ln -s /usr/share/dict/linux.words . screenshot

    5. (Optional) To load a larger payload (such as a DVD file), you can use Filezilla (or scp) to copy the file over. You will want to have changed the nginx document root directory owner to lanforge (as above):

      1. From your desktop, using Filezilla screenshot

        1. quick connect to sftp://192.168.100.40 (also named jed-f20 in this example)

        2. using username lanforge and password lanforge

      2. In the left column, choose your local directory (Y:\downloads) screenshot

      3. In the right column, type in the nginx document root, /usr/local/lanforge/nginx/html and hit enter screenshot

      4. In the left column, double-click your DVD image (Fedora-20-x86_64.netinst.iso) screenshot

      5. you will see the file when it is transferred appear in the right column screenshot

  5. Configure application-layer traffic using the Layer-4 tab tools:

    1. In the Layer-4 tab, click the Create button, screenshot

    2. You will see the Create/Modify L4Endpoint window

    3. Create a connection named web-requests,

    4. With a Report timer of fast (1 s)

    5. from Resource (jed-f20) port rd0b.

    6. Let's make ten requests a second. Enter 6000 for URLs per 10m.

    7. Jump down to the URL field, and enter http://10.2.0.1/index.html

    8. and to avoid saving the result, set the Dest File to /dev/null

    9. Click OK and the window will close. screenshot

  6. Running the traffic is simple:

    1. Select the row named web-requests in the Layer-4 table,

    2. Click the Start button. screenshot

    3. Click the Display button to see more detail on the traffic: screenshot

  7. It is also possible to verify your connection setup from the command-line:

    1. To verify the Layer 3 connection, you can use ping:
      ping -I 10.2.0.3 10.2.0.1 screenshot

    2. To see that nginx is listening on port 80, use netstat on the resource running nginx and see what is listening on port 80:
      sudo netstat -ntlp | grep ':80' screenshot

    3. To see the output of the web request, you can use LANforge's version of curl located in /home/lanforge/local/bin/curl. Since it uses bundled libraries, first type:
      cd /home/lanforge && . ./lanforge.profile
      This sets up all environment variables and paths to work with the binaries and libraries shipped with LANforge. screenshot

    4. Verify it runs without complaint:
      /home/lanforge/local/bin/curl --help screenshot

    5. If you scroll up in your terminal, you will see options available in the output not found in a normal version of curl, like
      --dns_server, --dns_interface, --dns_ip4_addr, --dns_ip6_addr, --interface and --localaddr. We will use --interface next. screenshot

    6. Craft your download command: cd /home/lanforge/local/bin
      ./curl --interface 10.2.0.3 'http://10.2.0.1/index.html' screenshot

    7. You will see the html output in the terminal: screenshot

    8. There will be a record of connections and errors in the nginx logs directory: cd /usr/local/lanforge/nginx/logs screenshot

  8. [Advanced] Creating IPv6 traffic to nginx. We will assume a scenario where eth1 will serve nginx requests and eth2 will generate requests.

    1. Add IPv6 addresses to your ports. We will add

      • ee::2:1/120 for eth1,
      • ee::2:2/120 for eth2,
      • and set the gateways for them to ee::2:fe. We won't actually use a gateway, but our port configuration requires it.

      1. Here is eth1, and we will enable the HTTP service as well. screenshot

      2. Here is eth2, notice how we added an IPv4 address to the port. Do that so that the Create Layer-4 dialog does not complain. screenshot

      3. Here is a picture of the Port Mgr tab, with ports on two resources configured. screenshot

      4. Verify your connection between ports using ping6: $ ping6 -I ee::2:2%eth2 ee::2:1

    2. Edit your /home/lanforge/vr_conf/nginx_eth1.conf file. You will remove the header comment and alter the listen statements to include IPv6 addresses. You can listen for [::] or you could listen for [ee::2:1] screenshot

    3. If you provide an IPv6 address, please watch the nginx log file for errors: listening on an IPv6 address is easy to misconfigure. The log files can be found in /usr/local/lanforge/nginx/logs

    4. Re-start the http service on eth1 by un-checking HTTP, clicking Apply, checking HTTP, clicking OK.

    5. Configure your Layer-4 endpoint: screenshot

      1. Name your endpoint

      2. Set your URLs per Minute

      3. Specify the URL with brackes around the address: http://[ee::2:1]/index.html

      4. Set your output file to /dev/null

    6. You can watch traffic on eth1 or eth2 to verify the web requests.


Candela  Technologies, 2417 Main Street, Suite 201, Ferndale, WA 98248, USA
www.candelatech.com | sales@candelatech.com | +1.360.380.1618
Google+ | Facebook | LinkedIn | Blog