# Use a proxy with curl

Demonstrates HTTP/HTTPS CONNECT and SOCKS5 TCP requests using fixed username and password gateways and environment credentials.

The curl example is suitable for minimal authentication and server health checks. True values are injected only through controlled environment variables or keys.

## HTTP/HTTPS

```bash
curl --connect-timeout 10 --max-time 30 \
  --proxy 'http://us.zzhttp.com:7878' \
  --proxy-user "$PROXY_USERNAME:$PROXY_PASSWORD" \
  'https://ipinfo.io/json'
```

## SOCKS5 TCP

```bash
curl --connect-timeout 10 --max-time 30 \
  --proxy 'socks5h://us.zzhttp.com:7878' \
  --proxy-user "$PROXY_USERNAME:$PROXY_PASSWORD" \
  'https://ipinfo.io/json'
```

## Prepare

- Get the full proxy username and sub-username and password from the console and inject them separately `PROXY_USERNAME` and `PROXY_PASSWORD`; Indicative value `ab******9Z`, `p8******K2` Cannot be used for authentication.
- Avoid displaying passwords in shell history and CI output.

## Implementation

- HTTP proxies can access HTTP or HTTPS targets.
- SOCKS5 domain name requests `socks5h`.

## Verification steps

1. Place the real configuration in a controlled environment variable or temporary credential store, without writing the full proxy URL to the script store.
2. Run HTTP/HTTPS and HTTPS separately `socks5h` For example, retain connection timeouts and overall timeouts.
3. Check HTTP status codes and JSON `ip`, `country`, `region` Exports and selected regions were compared with those without the use of agents. Geographical locations are from third-party databases and the results for cities may be biased.

## Expected results

- The command returns successful within the 30-second total timeout, and the output IP in the response is different from the local public IP.
- `socks5h` The target domain name is resolved by the proxy side, avoiding passing the domain name to the local DNS first.

## Failure border

- curl exits while parsing the command or proxy URL, indicating that the request has not yet reached the gateway;`407` The certification phase is only indicated by the number of points.
- Successful address detection does not guarantee accessibility to any target, target `403`, `429` and business contents are subject to independent judgment.

## Security

- The debug output requires the removal of Proxy-Authorization.
- Do not paste the entire command with the password into the worksheet.

html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}
