Skip to content

Commit 11e16b4

Browse files
committed
docs: add squid config content
1 parent 4693c97 commit 11e16b4

File tree

1 file changed

+174
-2
lines changed

1 file changed

+174
-2
lines changed

content/nginx-one/agent/configure-instance-reporting/connect-using-squid.md

Lines changed: 174 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,147 @@ Ensure you have the following:
1717

1818
## Configure Squid
1919

20-
TBD
20+
### Install Squid
21+
22+
{{<tabs name="Install_Squid">}}
23+
{{%tab name="Mac OS"%}}
24+
25+
1. Open a terminal window.
26+
1. Install Squid using Homebrew:
27+
28+
```sh
29+
brew install squid
30+
```
31+
1. Start the Squid service:
32+
33+
```sh
34+
brew services start squid
35+
```
36+
---
37+
38+
{{%/tab%}}
39+
{{%tab name="Ubuntu (including running it under WSL)"%}}
40+
41+
Run the following commands as a superuser:
42+
43+
1. Open a terminal window.
44+
1. Update the package list:
45+
```sh
46+
sudo apt-get update
47+
```
48+
1. Install Squid:
49+
```sh
50+
sudo apt-get install squid -y
51+
```
52+
1. Start the Squid service:
53+
```sh
54+
sudo systemctl start squid
55+
```
56+
---
57+
58+
{{%/tab%}}
59+
{{</tabs>}}
60+
61+
62+
### Configure Squid
63+
64+
Follow the steps below to configure Squid with basic authentication.
65+
66+
{{<tabs name="Configure_Squid">}}
67+
{{%tab name="Mac OS"%}}
68+
69+
1. Set up an HTTP Proxy with Basic Authentication. This setup requires users to provide a username and password. Run the
70+
following commands as a superuser:
71+
72+
```sh
73+
htpasswd -c /usr/local/squid/passwd your_user # Create a user
74+
```
75+
76+
- You will be prompted to enter and confirm a password for `your_user`.
77+
78+
1. Locate the Squid configuration file:
79+
- Run `squid -v` to find the configuration file path. Look for the `--sysconfdir` flag (usually `/usr/local/etc/squid/squid.conf` or `/opt/homebrew/etc/squid.conf` on Mac OS).
80+
81+
1. Find the path to your basic_ncsa_auth program:
82+
- On Mac OS, it is usually be located at `/opt/homebrew/Cellar/squid/7.1/libexec/basic_ncsa_auth`. You can get the version number from the `squid -v` command output.
83+
84+
1. Open the Squid configuration file with a text editor (you might need superuser privileges):
85+
86+
```sh
87+
sudo nano <path to config file>/squid.conf
88+
```
89+
90+
1. Add or modify the following lines (usually at the top of the file) to configure the proxy settings:
91+
92+
```conf
93+
auth_param basic program <path_to_basic_ncsa_auth>/basic_ncsa_auth /usr/local/etc/squid/passwd auth_param basic realm Squid proxy-caching web server acl authenticated proxy_auth REQUIRED
94+
```
95+
96+
1. In the same configuration file, find the line that starts with `http_access deny all` and add the `http_access allow authenticated` line above it. It should look like this:
97+
98+
```conf
99+
http_access allow authenticated
100+
http_access deny all
101+
```
102+
103+
1. Save the changes and exit the text editor.
104+
1. Restart the Squid service to apply the changes:
105+
106+
```sh
107+
brew services restart squid
108+
```
109+
110+
---
111+
112+
{{%/tab%}}
113+
{{%tab name="Ubuntu"%}}
114+
115+
1. Set up an HTTP Proxy with Basic Authentication. This setup requires users to provide a username and password. Run the
116+
following commands as a superuser:
117+
118+
```sh
119+
apt-get install apache2-utils -y # Install htpasswd utility
120+
htpasswd -c /usr/local/squid/passwd your_user # Create a user
121+
```
122+
123+
- You will be prompted to enter and confirm a password for `your_user`.
124+
125+
1. Locate the Squid configuration file:
126+
- Run `squid -v` to find the configuration file path. Look for the `--sysconfdir` flag (usually `/etc/squid/squid.conf` on Ubuntu).
127+
128+
1. Find the path to your basic_ncsa_auth program:
129+
- On Ubuntu, it is usually located at `/usr/lib/squid/basic_ncsa_auth`.
130+
131+
1. Open the Squid configuration file with a text editor (you might need superuser privileges):
132+
133+
```sh
134+
sudo nano <path to config file>/squid.conf
135+
```
136+
137+
1. Add or modify the following lines (usually at the top of the file) to configure the proxy settings:
138+
139+
```conf
140+
auth_param basic program <path_to_basic_ncsa_auth>/basic_ncsa_auth /usr/local/etc/squid/passwd auth_param basic realm Squid proxy-caching web server acl authenticated proxy_auth REQUIRED
141+
```
142+
143+
1. In the same configuration file, find the line that starts with `http_access deny all` and add the `http_access allow authenticated` line above it. It should look like this:
144+
145+
```conf
146+
http_access allow authenticated
147+
http_access deny all
148+
```
149+
150+
1. Save the changes and exit the text editor.
151+
1. Restart the Squid service to apply the changes:
152+
153+
```sh
154+
sudo systemctl restart squid
155+
```
156+
157+
---
158+
159+
{{%/tab%}}
160+
{{</tabs>}}
21161

22162
## NGINX Agent Proxy configuration
23163

@@ -97,4 +237,36 @@ To set proxy authentication in a containerized environment:
97237

98238
## Validate connectivity between NGINX Agent, Squid, and NGINX One Console
99239

100-
TBD
240+
To test the connectivity between NGINX Agent, Squid, and NGINX One Console, you can use the `curl` command with the proxy settings.
241+
242+
1. Open a secure connection to your instance using SSH and log in.
243+
1. Run the following `curl` command to test the connection:
244+
```sh
245+
curl -x http://proxy.example.com:3128 -U your_user:your_password https://mgmt.example.com/api/v1/agents
246+
```
247+
248+
- Replace `proxy.example.com:3128` with your Squid proxy address and port.
249+
- Replace `your_user` and `your_password` with the credentials you set up for Squid in the previous steps.
250+
- Replace `mgmt.example.com` with your NGINX One Console address.
251+
252+
To test the configuration from a containerized environment, run the following command from within the container:
253+
254+
```sh
255+
curl -x http://host.docker.internal:3128 -U your_user:your_password https://mgmt.example.com/api/v1/agents
256+
```
257+
258+
- Replace `your_user` and `your_password` with the credentials you set up for Squid in the previous steps.
259+
- Replace `mgmt.example.com` with your NGINX One Console address.
260+
261+
## Troubleshooting
262+
263+
1. Find the configuration and log files:
264+
265+
- Run `squid -v`.
266+
- Look for the `--sysconfdir` flag (usually `/usr/local/etc/squid/squid.conf` or `/opt/homebrew/etc/squid.conf` on
267+
Mac OS, and `/etc/squid/squid.conf` on Ubuntu) to find the configuration file.
268+
- Look for the `--prefix` flag to find the log file path (usually `/usr/local/var/logs/squid` or `/opt/homebrew/var/logs/squid`
269+
on Mac OS, and `/var/log/squid` on Ubuntu) to find the log files.
270+
- Look for the `--localstatedir` flag to find the cache directory path (usually `/usr/local/var/cache/squid` or `/opt/homebrew/var/cache/squid`
271+
on Mac OS, and `/var/spool/squid` on Ubuntu) to find the cache directory.
272+

0 commit comments

Comments
 (0)