Hypertest Docs
HyperTestKnowledge Base
  • Quick Set-up
    • Install HyperTest
    • Deploy your application
    • Mirror Traffic
      • Using Kubernetes
      • Using Amazon ECS
      • Using Docker
      • Using Nginx
      • Using Goreplay
        • ElasticBeanStalk Script for Goreplay
      • Using Apache
      • Using IIS
      • Using Istio
      • Using Kong
      • Using HAProxy
      • Others
  • HyperTest Overview
    • Introduction
    • Architecture
  • Detailed Setup Guide
    • Detailed Setup Guide
      • Installation
        • Linux VM
        • Kubernetes Cluster
          • Hardware Requirements
          • Cluster Setup
            • EKS
              • Existing Application Load Balancer
              • Calculate Setup Cost for EKS Cluster
            • GCP
            • AKS
            • Self Managed
              • Microk8s with EKS-D
          • HyperTest Installation
      • Mirror Traffic
      • Configure HyperTest
      • Automate Starting a Test
        • CI Integration
          • GitHub Checks Integration
            • Mandatory checks
          • Gitlab Integration
          • Bitbucket Integration
          • Jenkins Pipeline
            • Jenkins Plugins for PR events
  • Upgrade HyperTest
    • Upgrade HyperTest
      • Linux VM
      • Kubernetes Cluster
  • User Guides
    • Usage Guide
      • Install and Configure HyperTest
        • Install HyperTest
        • Configure Base DNS
        • Add New Service
      • Tests Runs and Analysis
        • View Test Cases
        • Start New Test Run
        • Understand Your Test Run Analysis
        • Prioritize Your Error Types
        • Track Bugs
        • Ignore Errors/Desired Changes
        • View/Download Report
        • View Consolidated Dashboard Reports
        • Sign-off Reports
        • Reduce Execution Time
        • Deduplication Rules
      • Troubleshooting and FAQs
    • Best Practices Guide
      • Cost Optimization
    • Dashboard Tour
      • Dashboard
      • All Sessions
      • Regression Report
      • Notifications
      • First Test Run
      • Interactions
      • Custom Analysis
      • Configuration
    • User Management
      • Create Admin User
      • Roles, Groups & Users
      • Enabling User Signup
    • Other Guides
      • Basic Nginx Auth for Linux HT
  • Middleware
  • Advanced Features
    • Import test cases from Postman
  • Change Log
  • Troubleshooting
  • FAQs
    • Setup
    • General
    • Regression Report
  • Glossary
    • Session
Powered by GitBook
On this page
  • Existing Nginx
  • Deploying New Nginx Server as Proxy
  1. Quick Set-up
  2. Mirror Traffic

Using Nginx

PreviousUsing DockerNextUsing Goreplay

Last updated 1 year ago

Find the video guide for below instructions over .

In this guide, we will be using to mirror the traffic to Hypertest.

The below changes are only applicable on NGINX (>= 1.13.4)

Existing Nginx

If you are already running Nginx in your setup for your application, just add the following changes in your Nginx configuration.

Only copy the parts from ## copy from this till ## to this. Rest is just sample configuration file

sample nginx.conf
## copy from this ##
upstream hypertest-service-logger {
    server <hypertest-vm-ip>:<hypertest-logger-port>;
}
## to this ##

server {
  ## listen 8000;
    .
    .
      location / {
        .
        .
        ## copy from this ##
        mirror /mirror;
        mirror_request_body on;
        ## to this ##
        .
        .
        ## proxy_pass http://localhost:3000;
    }
    .
    .
    ## copy from this ##
    location   = /mirror {
      internal;
      if ($http_fromhypertest) {
          return 400 'mirror loop';
      }
      proxy_connect_timeout 500ms;
      proxy_read_timeout 500ms;
      proxy_pass http://hypertest-service-logger$request_uri;
      proxy_set_header x-real-host $http_host;
      proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
    }
    ## to this
    .
    .
}

Restart your Nginx server with new configuration changes.

To verify the mirroring setup, hit any api on the application and check for request in "last mirrored requests" section or Session page in HyperTest.

Deploying New Nginx Server as Proxy

If you are deploying Nginx as a new Proxy Server then create the below two files.

Here we are deploying one Nginx server which will run as docker container. The traffic coming to Nginx server (running on port 8003) will be forwarded to your candidate application and also will be mirrored to HyperTest.

Create a folder nginx-proxy

mkdir nginx-proxy
cd nginx-proxy

Create the file docker-compose.yml with below contents in it

docker-compose.yml
version: "3.7"

services:
  nginx:
    image: nginx:alpine
    container_name: external_nginx
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    network_mode: host
    restart: always

Create the below file nginx.conf with below contents in it

nginx.conf
upstream hypertest-logger {
  server <hypertest-vm-ip>:<logger-port>;
}

upstream candidate-application {
  server candidate.app.latest
}

server {
  listen 8003;
  client_max_body_size 600M;

  access_log off;
  	
  location / {
    mirror /mirror;
    mirror_request_body on;
    ## change this
    proxy_pass http://candidate-application;
    proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
    proxy_ssl_server_name on;
    proxy_ssl_name $host;
  }
    
  location   = /mirror {
    internal;
    if ($http_fromhypertest) {
      return 400 'mirror loop';
    }
    proxy_connect_timeout 500ms;
    proxy_read_timeout 500ms;
    proxy_pass http://hypertest-logger$request_uri;
    proxy_set_header x-real-host $http_host;
    proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
  }
} 

Start the Nginx server using below command:

docker-compose -f docker-compose.yml up -d

Now Nginx server should be up and running, you can check it using below command:

docker ps| grep nginx

To Verify the mirroring setup, hit any api on the application and check for request in "last mirrored requests" section or Session page in HyperTest.

here
Nginx