2018-05-25 10:32:42 -07:00
|
|
|
Warcprox - WARC writing MITM HTTP/S proxy
|
2018-05-22 11:59:06 -07:00
|
|
|
*****************************************
|
2016-10-19 17:30:53 -07:00
|
|
|
.. image:: https://travis-ci.org/internetarchive/warcprox.svg?branch=master
|
|
|
|
:target: https://travis-ci.org/internetarchive/warcprox
|
2013-11-28 01:24:30 -08:00
|
|
|
|
2018-05-30 14:12:58 -07:00
|
|
|
Warcprox is a tool for archiving the web. It is an http proxy that stores its
|
|
|
|
traffic to disk in `WARC
|
|
|
|
<https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/>`_
|
|
|
|
format. Warcprox captures encrypted https traffic by using the
|
|
|
|
`"man-in-the-middle" <https://en.wikipedia.org/wiki/Man-in-the-middle_attack>`_
|
|
|
|
technique (see the `Man-In-The_Middle`_ section for more info).
|
|
|
|
|
|
|
|
The web pages that warcprox stores in WARC files can be played back using
|
|
|
|
software like `OpenWayback <https://github.com/iipc/openwayback>`_ or `pywb
|
|
|
|
<https://github.com/webrecorder/pywb>`_. Warcprox has been developed in
|
|
|
|
parallel with `brozzler <https://github.com/internetarchive/brozzler>`_ and
|
|
|
|
together they make a comprehensive modern distributed archival web crawling
|
|
|
|
system.
|
|
|
|
|
|
|
|
Warcprox was originally based on the excellent and simple pymiproxy by Nadeem
|
|
|
|
Douba. https://github.com/allfro/pymiproxy
|
2013-11-28 01:24:30 -08:00
|
|
|
|
2018-05-25 10:32:42 -07:00
|
|
|
.. contents::
|
|
|
|
|
2018-05-30 14:12:58 -07:00
|
|
|
Getting started
|
|
|
|
===============
|
2017-12-21 15:45:39 -08:00
|
|
|
Warcprox runs on python 3.4+.
|
2014-08-08 12:22:33 -07:00
|
|
|
|
2018-05-30 14:12:58 -07:00
|
|
|
To install latest release run::
|
2014-08-08 12:53:16 -07:00
|
|
|
|
2017-05-24 13:57:09 -07:00
|
|
|
# apt-get install libffi-dev libssl-dev
|
2014-08-08 12:22:33 -07:00
|
|
|
pip install warcprox
|
|
|
|
|
2018-05-30 14:12:58 -07:00
|
|
|
You can also install the latest bleeding edge code::
|
2014-08-08 12:53:16 -07:00
|
|
|
|
2014-08-08 12:22:33 -07:00
|
|
|
pip install git+https://github.com/internetarchive/warcprox.git
|
|
|
|
|
2018-05-30 14:12:58 -07:00
|
|
|
To start warcprox run::
|
|
|
|
|
|
|
|
warcprox
|
|
|
|
|
|
|
|
Try ``warcprox --help`` for documentation on command line options.
|
|
|
|
|
|
|
|
Man-In-The-Middle?
|
|
|
|
==================
|
|
|
|
Traffic to and from https sites is encrypted. Normally http proxies can't read
|
|
|
|
that traffic. The web client uses the http ``CONNECT`` method to establish a
|
|
|
|
tunnel through the proxy, and the proxy merely routes raw bytes between the
|
|
|
|
client and server. Since the bytes are encrypted, the proxy can't make sense of
|
|
|
|
the information it's proxying. Nonsensical encrypted bytes would not be very
|
|
|
|
useful to archive.
|
|
|
|
|
|
|
|
In order to capture https traffic, warcprox acts as a "man-in-the-middle"
|
|
|
|
(MITM). When it receives a ``CONNECT`` directive from a client, it generates a
|
|
|
|
public key certificate for the requested site, presents to the client, and
|
|
|
|
proceeds to establish an encrypted connection. Then it makes a separate, normal
|
|
|
|
https connection to the remote site. It decrypts, archives, and re-encrypts
|
|
|
|
traffic in both directions.
|
|
|
|
|
|
|
|
Although "man-in-the-middle" is often paired with "attack", there is nothing
|
|
|
|
malicious about what warcprox is doing. If you configure an instance of
|
|
|
|
warcprox as your browser's http proxy, you will see lots of certificate
|
|
|
|
warnings, since none of the certificates will be signed by trusted authorities.
|
|
|
|
To use warcprox effectively the client needs to disable certificate
|
|
|
|
verification, or add the CA cert generated by warcprox as a trusted authority.
|
|
|
|
(If you do this in your browser, make sure you undo it when you're done using
|
|
|
|
warcprox!)
|
2013-11-28 01:24:30 -08:00
|
|
|
|
2018-05-25 14:46:19 -07:00
|
|
|
API
|
|
|
|
===
|
|
|
|
For interacting with a running instance of warcprox.
|
|
|
|
|
|
|
|
* ``/status`` url
|
|
|
|
* ``WARCPROX_WRITE_RECORD`` http method
|
|
|
|
* ``Warcprox-Meta`` http request header and response header
|
|
|
|
|
|
|
|
See `<api.rst>`_.
|
|
|
|
|
2018-05-25 10:32:42 -07:00
|
|
|
Deduplication
|
|
|
|
=============
|
|
|
|
Warcprox avoids archiving redundant content by "deduplicating" it. The process
|
|
|
|
for deduplication works similarly to heritrix and other web archiving tools.
|
|
|
|
|
|
|
|
1. while fetching url, calculate payload content digest (typically sha1)
|
|
|
|
2. look up digest in deduplication database (warcprox supports a few different
|
|
|
|
ones)
|
2018-05-29 17:09:14 -07:00
|
|
|
3. if found, write warc ``revisit`` record referencing the url and capture time
|
2018-05-25 10:32:42 -07:00
|
|
|
of the previous capture
|
2018-05-29 17:09:14 -07:00
|
|
|
4. else (if not found),
|
|
|
|
|
2018-05-25 10:32:42 -07:00
|
|
|
a. write warc ``response`` record with full payload
|
|
|
|
b. store entry in deduplication database
|
|
|
|
|
|
|
|
The dedup database is partitioned into different "buckets". Urls are
|
|
|
|
deduplicated only against other captures in the same bucket. If specified, the
|
|
|
|
``dedup-bucket`` field of the ``Warcprox-Meta`` http request header determines
|
|
|
|
the bucket, otherwise the default bucket is used.
|
|
|
|
|
|
|
|
Deduplication can be disabled entirely by starting warcprox with the argument
|
|
|
|
``--dedup-db-file=/dev/null``.
|
|
|
|
|
2018-05-25 14:46:19 -07:00
|
|
|
Statistics
|
|
|
|
==========
|
|
|
|
Warcprox keeps some crawl statistics and stores them in sqlite or rethinkdb.
|
2018-05-29 16:57:15 -07:00
|
|
|
These are consulted for enforcing ``limits`` and ``soft-limits`` (see
|
2018-05-25 14:46:19 -07:00
|
|
|
`<api.rst#warcprox-meta-fields>`_), and can also be consulted by other
|
|
|
|
processes outside of warcprox, for reporting etc.
|
2018-05-22 11:59:06 -07:00
|
|
|
|
2018-05-29 16:57:15 -07:00
|
|
|
Statistics are grouped by "bucket". Every capture is counted as part of the
|
|
|
|
``__all__`` bucket. Other buckets can be specified in the ``Warcprox-Meta``
|
|
|
|
request header. The fallback bucket in case none is specified is called
|
|
|
|
``__unspecified__``.
|
|
|
|
|
|
|
|
Within each bucket are three sub-buckets:
|
2018-05-29 17:09:14 -07:00
|
|
|
|
|
|
|
* ``new`` - tallies captures for which a complete record (usually a ``response``
|
2018-05-29 16:57:15 -07:00
|
|
|
record) was written to warc
|
2018-05-29 17:09:14 -07:00
|
|
|
* ``revisit`` - tallies captures for which a ``revisit`` record was written to
|
2018-05-29 16:57:15 -07:00
|
|
|
warc
|
2018-05-29 17:09:14 -07:00
|
|
|
* ``total`` - includes all urls processed, even those not written to warc (so the
|
2018-05-29 16:57:15 -07:00
|
|
|
numbers may be greater than new + revisit)
|
|
|
|
|
|
|
|
Within each of these sub-buckets we keep two statistics:
|
|
|
|
|
2018-05-29 17:09:14 -07:00
|
|
|
* ``urls`` - simple count of urls
|
|
|
|
* ``wire_bytes`` - sum of bytes received over the wire, including http headers,
|
|
|
|
from the remote server for each url
|
|
|
|
|
|
|
|
For historical reasons, in sqlite, the default store, statistics are kept as
|
|
|
|
json blobs::
|
2018-05-22 11:59:06 -07:00
|
|
|
|
2018-05-29 17:09:14 -07:00
|
|
|
sqlite> select * from buckets_of_stats;
|
2018-05-25 14:46:19 -07:00
|
|
|
bucket stats
|
|
|
|
--------------- ---------------------------------------------------------------------------------------------
|
|
|
|
__unspecified__ {"bucket":"__unspecified__","total":{"urls":37,"wire_bytes":1502781},"new":{"urls":15,"wire_bytes":1179906},"revisit":{"urls":22,"wire_bytes":322875}}
|
|
|
|
__all__ {"bucket":"__all__","total":{"urls":37,"wire_bytes":1502781},"new":{"urls":15,"wire_bytes":1179906},"revisit":{"urls":22,"wire_bytes":322875}}
|
2018-05-22 11:59:06 -07:00
|
|
|
|
2018-01-24 16:07:45 -08:00
|
|
|
Plugins
|
2018-05-22 11:59:06 -07:00
|
|
|
=======
|
2018-05-22 12:02:49 -07:00
|
|
|
Warcprox supports a limited notion of plugins by way of the ``--plugin``
|
|
|
|
command line argument. Plugin classes are loaded from the regular python module
|
|
|
|
search path. They will be instantiated with one argument, a
|
|
|
|
``warcprox.Options``, which holds the values of all the command line arguments.
|
|
|
|
Legacy plugins with constructors that take no arguments are also supported.
|
|
|
|
Plugins should either have a method ``notify(self, recorded_url, records)`` or
|
|
|
|
should subclass ``warcprox.BasePostfetchProcessor``. More than one plugin can
|
|
|
|
be configured by specifying ``--plugin`` multiples times.
|
2018-01-24 16:07:45 -08:00
|
|
|
|
2018-03-05 20:22:22 -08:00
|
|
|
`A minimal example <https://github.com/internetarchive/warcprox/blob/318405e795ac0ab8760988a1a482cf0a17697148/warcprox/__init__.py#L165>`__
|
2018-01-24 16:07:45 -08:00
|
|
|
|
2016-04-06 19:37:16 -07:00
|
|
|
License
|
2018-05-22 11:59:06 -07:00
|
|
|
=======
|
2016-04-06 19:37:16 -07:00
|
|
|
|
|
|
|
Warcprox is a derivative work of pymiproxy, which is GPL. Thus warcprox is also
|
|
|
|
GPL.
|
|
|
|
|
2016-11-21 15:19:02 -08:00
|
|
|
* Copyright (C) 2012 Cygnos Corporation
|
2018-01-24 16:07:45 -08:00
|
|
|
* Copyright (C) 2013-2018 Internet Archive
|
2016-04-06 19:37:16 -07:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2013-11-28 01:24:30 -08:00
|
|
|
|