# Network proxy support

## Overview

The Trust1Connector allows running in a system where a network proxy is defined. Basic authentication on this is also supported.

When it will try to synchronise with the Distribution Service it will automatically detect if a network proxy is defined and provide with OS dialogs to enter the username and password if basic authentication is required.

These credentials are stored in the `proxy.json` file in the installation folder of the Connector. If you have changed your username, password or connecting to a different proxy the `proxy.json` should be deleted and the connector will ask the credentials upon next synchronisation moment.

## MacOS

### Squid 4.14

{% hint style="warning" %}
Apple sillicon has `/usr/local/` in a different location. Use `/opt/homebrew/` instead
{% endhint %}

Install squid

```bash
brew install squid
```

Start squid service

```bash
brew services start squid
```

Squid config file is stored at `/usr/local/etc/squid.conf`. (`/opt/homebrew/etc` on apple sillicon)

Comment or remove following line:

```
http_access allow localnet
```

Then similar to linux config (but with updated paths) add this:

```
auth_param basic program /usr/local/Cellar/squid/4.8/libexec/basic_ncsa_auth /usr/local/etc/squid_passwords
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
```

Note that path to `basic_ncsa_auth` may be different since it depends on installed version when using `brew`, you can verify this with `ls /usr/local/Cellar/squid/`. Also note that you should add the above just bellow the following section:

```
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
```

Now generate yourself a user:password basic auth credential (note: `htpasswd` and `htdigest` are also both available on MacOS)

```bash
htpasswd -c /usr/local/etc/squid_passwords username_you_like
```

Restart the squid service

```bash
brew services restart squid
```

#### Update network settings

Go to the network settings, on `Ethernet` or `Wifi` and click advanced

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FfIShfKX3FaurV3i4i7hL%2Fimage.png?alt=media\&token=bd62b7ed-d12c-41f1-8ea1-2db83eb6cadf)



In the advanced view, go to `proxies` and enable both HTTP and HTTPS web proxy.

After that fill in the proxy server and port. The username and password can be provided optionally (for testing we let the applications handle this)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FnOgG2gsWCQzw4lm6dSrW%2Fimage.png?alt=media\&token=01997bc5-8633-4db7-a887-446bdd800327)

Save these settings, and you will now get a pop-up when the Trust1Connector needs to authenticate for the proxy.

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FnypS8Ys1KhJeBvMKl4xK%2FProxy%20username.png?alt=media\&token=d5cfbd04-c470-4e38-86b1-269e121431e6)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FlYduVLVwyuxsNlg1QMUg%2FProxy%20password.png?alt=media\&token=a6e5f513-bfa8-4e58-8eb8-01a4f50b769f)

Fill in both here and when it's correct this will connect with the Distribution server once again.



### Proxyman

{% hint style="info" %}
Proxyman does not support basic authentication
{% endhint %}

You can downoad proxyman here; [https://proxyman.io/](https://proxyman.io/)

When opening it will automatically proxy all the requests of the system by automatically setting the network settings on your system.

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FqXH6DsXFStbUgvqjrFIw%2Fimage.png?alt=media\&token=970e2921-d0b2-4b4d-87a4-0e873599738a)

Now your system has a proxy that can be used for testing the Trust1Connector application. ( will be automatically detected )

## Windows

### Squid 4.14

#### cygwin

Install cygwin via [www.cygwin.com](https://www.cygwin.com)

Install the **libcrypt2** library.&#x20;

When installation is done, copy the libcrypt dll to squid, to make sure authentication works with squid

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FlGkwMjcU8ONE7AXtV7Ts%2Fimage.png?alt=media\&token=516a7d72-637e-4d10-afc1-9bccd605ab8c)

#### Squid

install squid from [https://squid.diladele.com/](https://squid.diladele.com/)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FHYkZnfBRVAo7FajJVCCc%2Fimage.png?alt=media\&token=74aa16aa-c78a-4331-b49b-5d210d4a69ed)



![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FRuYt02hVoH9yDj9qzXZd%2Fimage.png?alt=media\&token=ae1033a3-1785-47f2-95de-350bd363d611)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FeOcdQ9T6YZ9fH1lMSJrq%2Fimage.png?alt=media\&token=1d175c39-7ec3-4afc-8bcc-3c336d81f501)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FMhCN0ucxuyvVKiFImn77%2Fimage.png?alt=media\&token=171c28b0-7681-4a63-bb66-9eae5cce4eb2)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FNS5dEhi0eu4IyLDnHVRC%2Fimage.png?alt=media\&token=8fd54398-f265-48ad-af71-5b0ad4d37303)

When you click “Finish” the installation process is finished. You should see a squid application appearing in the tray. This application allows you to start/stop the squid service as well as change the squid configuration.



![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2F1FTDMSxlX3Lhww4CpOCa%2Fimage.png?alt=media\&token=f43b256f-4cc6-45a5-b44f-957fbe866198)

During installation the MSI installer opened TCP port 3128 required to connect to your Squid instance from another machines in your network. If for some reasons this does not work or works not as expected please follow these steps to open required TCP ports.

Type “Windows Firewall with Advanced Security” in the Start Search string on Windows 7 or 8 and press Enter. Click “Inbound Rules” and then “New Rule”.

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FaMxkeP3lGGcJ22HRwhR1%2Fimage.png?alt=media\&token=98b0bb2c-47ff-4f26-9cdb-b3cee00e21fc)

Create an inbound rule to allow clients connect to the 3128 TCP port, the default port where squid is running.

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2Fiq7c0jfqsTtWyQHXqhAW%2Fimage.png?alt=media\&token=69409242-f381-407f-a77e-f1360704b7dd)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2F4sE4An7CfzAuYG32UDW7%2Fimage.png?alt=media\&token=ac3b4232-d9c1-4042-887a-b7986ad26aaf)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FpnMyZy4uEtwYvg8wPTAf%2Fimage.png?alt=media\&token=fc661e9c-d2f6-4568-9e5b-9d1443eb7743)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FW2qiIMFEcoiv9dn3nJQ9%2Fimage.png?alt=media\&token=70197351-9542-4da6-9d78-20f79c1e8f0a)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FwWyHQhkbKjVX008sRyQ9%2Fimage.png?alt=media\&token=d0ade97f-7962-4a07-8aa3-398a0a4aed85)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2F9SLML2dgqM0A3oLXqHo8%2Fimage.png?alt=media\&token=303f4b82-d6f8-4124-bc09-3b3f32b79380)

Now we can configure the `squid proxy` to enable basic authentication for our tests. First we'll configure the squid config.

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FaLEb6pFrY33vniZVGy1Z%2Fimage.png?alt=media\&token=720b6655-41f4-4bdc-b989-dd19780138cd)

For this you can use the configuration below. Line 51-54 are the most important + we comment all the `http_access allow` variables except the `ncsa_users` one

```
#
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed

acl localnet src 10.0.0.0/8	# RFC1918 possible internal network
acl localnet src 172.16.0.0/12	# RFC1918 possible internal network
acl localnet src 192.168.0.0/16	# RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80		# http
acl Safe_ports port 21		# ftp
acl Safe_ports port 443		# https
acl Safe_ports port 70		# gopher
acl Safe_ports port 210		# wais
acl Safe_ports port 1025-65535	# unregistered ports
acl Safe_ports port 280		# http-mgmt
acl Safe_ports port 488		# gss-http
acl Safe_ports port 591		# filemaker
acl Safe_ports port 777		# multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#

# Only allow cachemgr access from localhost
# http_access allow localhost manager
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

auth_param basic program "/cygdrive/c/squid/lib/squid/basic_ncsa_auth.exe" "/cygdrive/c/squid/etc/.htpasswd"
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users


# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
# http_access allow localnet
# http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 3128

# Uncomment the line below to enable disk caching - path format is /cygdrive/<full path to cache folder>, i.e.
#cache_dir aufs /cygdrive/d/squid/cache 3000 16 256


# Leave coredumps in the first cache dir
coredump_dir /var/cache/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
refresh_pattern .		0	20%	4320

dns_nameservers 8.8.8.8 208.67.222.222

max_filedescriptors 3200
```

Next up we'll configure our user. We need to go to the squid folder for this.

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FUlwC32v4uBsstJ9FhULW%2Fimage.png?alt=media\&token=e2d650b4-0eee-4e22-ad8b-7db086bf20ba)

In `etc` we will store a `.htpasswd` file which will contain our. You can create the user that needs to be stored in this file in [https://hostingcanada.org/htpasswd-generator/](https://hostingcanada.org/htpasswd-generator/)

after this you can **stop** and **start** the squid service

The server side configuration is over. Now let’s configure the client side. For that you have to specify the proxy in the network settings

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FJR9czGkCllP0dAhimIsH%2Fimage.png?alt=media\&token=491fe49a-5576-46bf-a927-e5fbc3e6bfb7)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FbGhRRFvlpKGIUuinrEvi%2Fimage.png?alt=media\&token=a5ac9376-e88d-448c-b089-34f0539f3a95)

![](https://3092524840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7HCvAhXTAbT3Blaa86-112993382%2Fuploads%2FY74UaiWkhDK4CQBEdolb%2Fimage.png?alt=media\&token=5e273f65-559a-46f0-87d9-60a116e70003)

Provide the manual proxy server with ip `127.0.0.1` and port `3128` now you can save and test the Trust1Connector
