# 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.

## Curl and Proxy

If your package uses CURL for specific reasons a proxy should not be set via the `HTTP_PROXY` and `HTTPS_PROXY` system environment variables. Curl will use these no matter which URL you are trying to access.

This will cause issues with internall communication of the Trust1Connector, causing the API and Registry to not be able to communicate with eachother.

## 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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FHPBtcaqdnAAIpyYlI6Pc%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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FEBqa4VqxXoovtMQZIKqI%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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2F7xDKWjmXm4aSQ8nUOo58%2FProxy%20username.png?alt=media\&token=d5cfbd04-c470-4e38-86b1-269e121431e6)

![](https://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FOfYzg4cfJVr58i8B4CB7%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/>

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

![](https://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FuQPFUZdmZVT0aVjMHexf%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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FXcKPOOAfHgqrCv4uiLZm%2Fimage.png?alt=media\&token=516a7d72-637e-4d10-afc1-9bccd605ab8c)

#### Squid

install squid from <https://squid.diladele.com/>

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

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

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

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

![](https://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FUn1beLNQNVIs0KhRbSsY%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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FyAIveVPthoBMzihjTbpQ%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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2Fi15MRZvt2SiZMECrTQXW%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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2Foj2S8khN0XVmFHr81NUt%2Fimage.png?alt=media\&token=69409242-f381-407f-a77e-f1360704b7dd)

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

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

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

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

![](https://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FocOb5kHRGCAs6QWFHnXp%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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FQe5uvbjvyh47XGIk7FmL%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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FhZcuXYXNRtKAfc5d7Kgg%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/>

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://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FVVUVhNYkTmqxwzOnUygJ%2Fimage.png?alt=media\&token=491fe49a-5576-46bf-a927-e5fbc3e6bfb7)

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

![](https://1926565183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLX88XmbsIgpRg1jYeAc8%2Fuploads%2FpcFbHSnPASUTRM59e5bR%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
