# Proxy

The [Aitm Service](../commands/service "../commands/service") includes a proxy.

You need to configure your client to use it.

## How to use the service proxy

### With the aitm command

By default, a one-shot execution ([cli](cli "cli") or [acp](acp "acp")) ill create its own proxy. To use the service proxy, you need to pass the *--use-service* flag

Example:

* with the flag

```bash
# pi
aitm --use-service pi
# starting jupyter
aitm --use-service cli jupyter
# starting a third app
aitm --use-service bash -c "my-app"
```

* with the *AITM_USE_SERVICE* [environment](env "env")

```bash
AITM_USE_SERVICE=1 aitm pi
```

### Manually with OS environment

You can set them manually.

* You get the service via the command:

```bash
aitm service env
aitm service env --format bash
aitm service env --format python
```

* And you set them in your env. Example for [Bash](../commands/bash "../commands/bash"):

```bash
eval "$(aitm service env --format bash)"
# or copy/paste the output of aitm service env --format bash
export HTTP_PROXY=http://localhost:8080
export HTTPS_PROXY=http://localhost:8080
export http_proxy=http://localhost:8080
export https_proxy=http://localhost:8080
export NODE_EXTRA_CA_CERTS=/home/user/.mitmproxy/mitmproxy-ca-cert.pem
export REQUESTS_CA_BUNDLE=/home/user/.mitmproxy/mitmproxy-ca-cert.pem
export SSL_CERT_FILE=/home/user/.mitmproxy/mitmproxy-ca-cert.pem
export CURL_CA_BUNDLE=/home/user/.mitmproxy/mitmproxy-ca-cert.pem
```

### Manually with the PAC file (Proxy Auto-Config)

If you client supports *proxy auto-detection*, you can pass it on of the 2 *proxy auto-configuration Url file* format:

* *http\://localhost:{proxy_port}/wpad.dat*
* and *http\://localhost:{proxy_port}/wpad.pac*

You still need to set manually in the client store the certificate if they are not installed on your operating system.

## Configuration

### Port

The default value of the proxy port is by default *8080*

You can set a different one with:

* the cli flag *-pp* or *--proxy-port*
* or the [environment variable](env "env") *AITM_PROXY_PORT*

If the port is taken:

* you can force its use by kill the process taking the port with the *--force* flag

* otherwise if the run is a:

  <!-- -->

  * [service run](../commands/service "../commands/service"), Aitm will exit with an error
  * one-shot run, Aitm will take the next available port

## Support

### Certificate problem

If you don't want to install the [certificate](certificate "certificate"), use the HTTP url so that clients don't need to validate certificates
