<commit_before># proxy-pac-proxy

Software development in network environments where Internet access is
forced through dynamically configured HTTP proxies is a pain. The
simple use of common package managers such as
[npm](https://www.npmjs.com/),
[pip](https://pypi.python.org/pypi/pip), [gem](https://rubygems.org/)
or [docker](https://www.docker.com/), perhaps in combination with
services and repositories on the local network, requires reverse
engineering of a *proxy.pac* file and the configuration of arbitrarily
complicated combinations of the usual *_PROXY environment
variables. Worse, if the proxy requires authentication, passwords will
quickly spread in environment variables and *.bash_history* files.

*Proxy-pac-proxy* tries to alleviate at least some of that pain.


## Installation

> Note: proxy-pac-proxy requires at least Node v7.6.0

To install *proxy-pac-proxy* on your system run:

```
$ npm install -g proxy-pac-proxy
```


## Quick Start

Export the *proxy.pac* URL (optional, but if the environment variable
is not set, the URL will need to be provided as a command line
argument):

```
$ export PROXYPACPROXY_URL=http://my.company.com/proxy.pac
```

Start the forwarding proxy server with authentication:

```
$ proxy-pac-proxy start -A
Username: joedoe
Password for <PASSWORD>: [hidden]
proxy succesfully started

```

Automatically configure appropriate *_PROXY environment variables for
steering traffic through the new forwarding proxy:

```
$ $(proxy-pac-proxy env)
```

Test:

```
$ curl -v http://example.com
* Rebuilt URL to: http://example.com/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to (nil) (127.0.0.1) port 8079 (#0)
> GET http://example.com/ HTTP/1.1
> Host: example.com
> User-Agent: curl/7.52.1
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 OK
< date: Sat, 30 Sep 2017 09:16:36 GMT
< etag: "359670651+ident"
< vary: Accept-Encoding
< server: ECS (dca/24D1)
< expires: Sat, 07 Oct 2017 09:16:36 GMT
< x-cache: HIT, HIT from 10.29.176.45
< content-type: text/html
< cache-control: max-age=604800
< last-modified: Fri, 09 Aug 2013 23:54:35 GMT
< content-length: 1270
< proxy-connection: Keep-Alive
< Connection: keep-alive
< ...
```


## Retrieving the proxy.pac URL

The *proxy.pac* URL can be configured in many ways, depending on the
operating system and the configuration approach (autodiscovery, remote
admin...). One way to retrieve the URL is on the
*chrome://net-internals* tab in Chrome:

![Chrome net-internals screenshot](https://user-images.githubusercontent.com/13051155/31044689-427be710-a5d4-11e7-99e5-329710079570.png)


## Limitations

 * Only supports Basic Authentication

 * Only slightly more secure than storing credentials in environment
   variables. With basic authentication Base64-encode passwords are
   transmitted in cleartext

     * Do not use authentication unless you totally trust the local
       network administrator; in that's not the case, then leave
       authentication unset (i.e. don't use `-A` or `-U` options) and
       rely on application-based authentication

<commit_msg>Replaced screenshot with sensible info<commit_after># proxy-pac-proxy

Software development in network environments where Internet access is
forced through dynamically configured HTTP proxies is a pain. The
simple use of common package managers such as
[npm](https://www.npmjs.com/),
[pip](https://pypi.python.org/pypi/pip), [gem](https://rubygems.org/)
or [docker](https://www.docker.com/), perhaps in combination with
services and repositories on the local network, requires reverse
engineering of a *proxy.pac* file and the configuration of arbitrarily
complicated combinations of the usual *_PROXY environment
variables. Worse, if the proxy requires authentication, passwords will
quickly spread in environment variables and *.bash_history* files.

*Proxy-pac-proxy* tries to alleviate at least some of that pain.


## Installation

> Note: proxy-pac-proxy requires at least Node v7.6.0

To install *proxy-pac-proxy* on your system run:

```
$ npm install -g proxy-pac-proxy
```


## Quick Start

Export the *proxy.pac* URL (optional, but if the environment variable
is not set, the URL will need to be provided as a command line
argument):

```
$ export PROXYPACPROXY_URL=http://intranet.mycompany.com/proxy.pac
```

Start the forwarding proxy server with authentication:

```
$ proxy-pac-proxy start -A
Username: joedoe
Password for <PASSWORD>: [hidden]
proxy succesfully started

```

Automatically configure appropriate *_PROXY environment variables for
steering traffic through the new forwarding proxy:

```
$ $(proxy-pac-proxy env)
```

Test:

```
$ curl -v http://example.com
* Rebuilt URL to: http://example.com/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to (nil) (127.0.0.1) port 8079 (#0)
> GET http://example.com/ HTTP/1.1
> Host: example.com
> User-Agent: curl/7.52.1
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 OK
< date: Sat, 30 Sep 2017 09:16:36 GMT
< etag: "359670651+ident"
< vary: Accept-Encoding
< server: ECS (dca/24D1)
< expires: Sat, 07 Oct 2017 09:16:36 GMT
< x-cache: HIT, HIT from 10.29.176.45
< content-type: text/html
< cache-control: max-age=604800
< last-modified: Fri, 09 Aug 2013 23:54:35 GMT
< content-length: 1270
< proxy-connection: Keep-Alive
< Connection: keep-alive
< ...
```


## Retrieving the proxy.pac URL

The *proxy.pac* URL can be configured in many ways, depending on the
operating system and the configuration approach (autodiscovery, remote
admin...). One way to retrieve the URL is on the
*chrome://net-internals* tab in Chrome:

![Chrome net-internals screenshot](https://user-images.githubusercontent.com/13051155/31044770-b59dc0aa-a5d5-11e7-931c-0f0b0ceb3f8c.png)


## Limitations

 * Only supports Basic Authentication

 * Only slightly more secure than storing credentials in environment
   variables. With basic authentication Base64-encode passwords are
   transmitted in cleartext

     * Do not use authentication unless you totally trust the local
       network administrator; in that's not the case, then leave
       authentication unset (i.e. don't use `-A` or `-U` options) and
       rely on application-based authentication


{'fraction_non_alphanumeric': 0.10837755266119956, 'fraction_numerical': 0.04405853031033928, 'mean_word_length': 4.222502099076406, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 19, 'https://': 10, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2692456', 'n_tokens_mistral': 2163, 'n_tokens_neox': 1877, 'n_words': 698}