for more information on how to collect traffic with Mashape Galileo, please visit getgalileo.com/docs
HARchiver is a proxy made to be portable, fast and transparent, it takes incoming HTTP/HTTPS calls and routes them to their final destination, collecting stats in the background without slowing down the request itself.
We offer a free, public HARchiver cloud proxy available at proxy.analytics.mashape.com
, operating on port 80
for HTTP, and port 443
for HTTPS.
Make sure to send the Mashape-Service-Token
header to indicate where to route your logs.
Notes:
-
By default, requests are proxied on the same protocol they were received. To override that, send the header
Mashape-Upstream-Protocol
with the valuesHTTP
orHTTPS
. That makes it possible to query HTTPS-only APIs without enabling HTTPS mode inHARchiver
. -
There's also the
Mashape-Host-Override
header for use when theHost
header cannot be set, such as in browser XmlHttpRequest (AJAX).
Linux (For OSX and Windows use Docker)
Grab the latest release, then follow the instructions below:
wget https://github.com/Mashape/harchiver/releases/download/[VERSION]/harchiver.tar.gz
tar xzvf harchiver.tar.gz
cd release
./harchiver
- If the program reports a GLIBC error on startup, please open a Github Issue.
- If you expect massive load, up the server's
ulimit
The only thing needed is to create a container with the correct port forwarding and command-line options from the image.
# Download the image
docker pull mashape/harchiver
# Then make a container from it
docker run -p 15000:15000 --name="harchiver_http" mashape/harchiver
# or with some options:
docker run -p 15000:15000 --name="harchiver_http" mashape/harchiver /release/harchiver 15000 SERVICE_TOKEN
There's now a container named harchiver_http
that can be started easily with docker start harchiver_http
. That container can be removed and recreated from the mashape/harchiver
image easily to change the command-line options.
The certificate and key must be copied into a new image based on the mashape/harchiver
image.
On boot2docker, don't forget to run $(boot2docker shellinit)
.
# Download the image
docker pull mashape/harchiver
# Then make a basic container
docker run -p 15000:15000 --name="harchiver_http" mashape/harchiver
# Let it run and switch to a new terminal window
# Remember that the certificate and key MUST be named cert.pem and key.pem
# Copy the certificate and the key into the container
docker exec -i harchiver_http bash -c 'cat > /key.pem' < key.pem
docker exec -i harchiver_http bash -c 'cat > /cert.pem' < cert.pem
# Stop the container
docker kill harchiver_http
# Save it as a new image
docker commit -m "Added https support" harchiver_http harchiver_image_https
# Create a container from it
docker run -p 15000:15000 -p 15001:15001 --name="harchiver_https" harchiver_image_https /release/harchiver 15000 -https 15001 SERVICE_TOKEN
You can use HARchiver as a proxy layer between your application and any local or remote API server.
┌─────────────┐
│ Private API │
└─────────────┘
▲
┌─────┘ ┌─────────────────┐
│ ┌─▶│ API Provider #1 │
┌─────────────┐ ┌─────────────┐ │ └─────────────────┘
│ Application │───▶│ HARchiver │─┤ ┌─────────────────┐
└─────────────┘ └─────────────┘ └─▶│ API Provider #2 │
└─────────────────┘
Start HARchiver on port 15000
with your Mashape Analytics Service Token:
./harchiver 15000 SERVICE_TOKEN
Now you can send requests through the HARchiver using the Host
header, here's an example of making a GET request to http://mockbin.org/request
through the HARchiver proxy:
curl -H "Host: mockbin.org" -H "Mashape-Upstream-Protocol: HTTP" http://127.0.0.1:15000/get
That's it, your data is now available on Mashape Analytics!
To capture all incoming traffic to your API, start HARchiver on port 15000
in reverse-proxy mode with your Mashape Analytics Service Token:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│The Internet │────▶│ HARchiver │────▶│ Your API │
└─────────────┘ └─────────────┘ └─────────────┘
./harchiver 15000 -reverse 10.1.2.3:8080 SERVICE_TOKEN
In this example, 10.1.2.3:8080
is the location of your API. All incoming requests will be directed there.
HARchiver can do SSL termination itself (-https
option), but if you're already using nginx to do so, you should simply make nginx proxy to HARchiver which proxies to your application. See the network diagram below
┌─────────────┐ ┌───────────┐
┌─▶│ HARchiver │──────▶│ API #1 │
┌─────────────┐ │ └─────────────┘ └───────────┘
┌─────────────┐ │ nginx │ │ ┌─────────────┐ ┌───────────┐
│The Internet │───▶│ HAproxy │─┼─▶│ HARchiver │──────▶│ API #2 │
└─────────────┘ │ SSL │ │ └─────────────┘ └───────────┘
└─────────────┘ │ ┌─────────────┐ ┌───────────┐
└─▶│ HARchiver │──────▶│ API #3 │
└─────────────┘ └───────────┘
The SSL termination (aka decryption) can be either done in nginx/HAproxy or HARchiver.
Note:
-
HARchiver uses only 20Mb of RAM and should be located on the same machine as your API Servers to reduce latency and simplify configuration.
-
if running multiple services per ip, You can inspect the
Host
header in your code to determine what service the client requested, if necessary, or if you wish to limit HARchiver to a specific service / host, use the host name instead of an IP in the previous step.
curl http://127.0.0.1:15000/some/url/on/the/api
That's it, your data is now available on Mashape Analytics!
harchiver PORT [SERVICE_TOKEN]
- Without
SERVICE_TOKEN
the HTTP headerMashape-Service-Token
must be set on every request.
Flag | Description | Default |
---|---|---|
-c NB |
maximum number of concurrent requests. | 500 |
-debug |
output the generated data on-the-fly | - |
-https PORT |
add HTTPS support. The files key.cert & cert.pem need to be in the same directory as HARchiver |
- |
-replays |
enable replays by sending the body of the requests in the ALF | - |
-reverse target |
start in reverse-proxy mode | - |
-t TIMEOUT |
set remote server response timeout in seconds. | 6 |
-version |
displays the version number | |
-help |
displays usage instructions |
Copyright Mashape Inc, 2015.
Licensed under the MIT License