Find the video guide for below instructions over here.
In this guide, we will be using Nginx 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