# Run Cody via proxies

<p className="subtitle">
	This documentation helps you set up HTTP, HTTPS, and SOCKS proxies in VS
	Code and JetBrains IDEs. It also includes instructions for handling
	self-signed certificates on macOS and Windows.
</p>

<Tabs>
  <Tab title="Proxy Setup for VS Code">

{' '}
<Callout type="info">
	{' '}
	You may be unable to authenticate with Cody or see a network reachability issue
	if you attempt to use Cody before configuring your proxy settings.
</Callout>

### Accessing the Proxy Settings

1. Open VS Code.
2. Navigate to the settings window of VS Code
3. In the search bar at the top of the Settings pane, type `proxy`
4. Click on `Edit in settings.json` to open the `settings.json` file

### Modifying `settings.json` for Proxy Configuration

Add the following configuration fields in the `settings.json` file to set up your proxy:

```json
{
	"http.proxy": "http://proxy_ip:port", // Replace with your proxy IP and port
	"http.proxySupport": "on",
	"http.proxyStrictSSL": true,
	"http.systemCertificates": true,
	"http.experimental.systemCertificatesV2": true
}
```

### Self-Signed Certificates in VS Code

If your proxy uses self-signed certificates, ensure the following settings are enabled:

```json
{
	"http.systemCertificates": true,
	"http.experimental.systemCertificatesV2": true
}
```

### Restart VS Code

After modifying the `settings.json` file, close and restart VS Code to apply the new proxy settings.

### Supported Proxy Types

VS Code supports HTTP, HTTPS, and SOCKS proxies. The `http.proxy` setting in `settings.json` will accommodate all three types based on the provided proxy URL.

  </Tab>

  <Tab title="Proxy Setup for JetBrains">

{' '}
<Callout type="info">
	{' '}
	You may be unable to authenticate with Cody or see a network reachability issue
	if you attempt to use Cody before configuring your proxy settings.
</Callout>

### Accessing the Proxy Settings

1. Open your JetBrains IDE (e.g., IntelliJ IDEA, PyCharm)
2. Navigate to `Settings` by clicking on `File` > `Settings` (or `Preferences` on macOS)
3. In the search bar at the top, type `proxy` to find the proxy settings
4. Select the `HTTP` proxy or `SOCKS` proxy based on your requirement

### Configuring HTTP Proxy

1. In the proxy settings, choose `Manual Proxy Configuration`
2. Enter the following details:
    - **HTTP Proxy:** `http://proxy_ip:port` (Replace with your proxy IP and port)
    - **Enable proxy authentication if needed and provide credentials**
3. Click `Apply` and then `OK` to save the settings

### Configuring SOCKS Proxy

1. In the proxy settings, choose `Manual Proxy Configuration`
2. Enter the following details:
    - **SOCKS Proxy:** `socks5://proxy_ip:port` (Replace with your proxy IP and port)
    - **Enable proxy authentication if needed and provide credentials**
3. Click `Apply` and then `OK` to save the settings

### Using the Proxy with Cody

1. Open Cody settings within your JetBrains IDE
2. Connect to the Sourcegraph instance using the provided instance IP and token:
    - **Instance IP:** `http://instance_ip`
    - **Token:** `your_token`
3. Click `Apply`, then `OK`, and test the connection

### Supported Proxy Types

JetBrains supports HTTP and SOCKS proxies. The `Manual Proxy Configuration` in the settings will accommodate both types based on the provided proxy URL.

### Known Limitations

1. Currently, only `Manual Proxy Configuration` is supported. The `auto-detect proxy settings` option is not fully supported.
2. HTTPS proxy is not supported in JetBrains currently

  </Tab>

</Tabs>

## Troubleshooting the Proxy Setup

### Basic Connectivity Test

To verify that your proxy setup works, use the following `curl` command in your terminal, replacing `proxy_ip` and `instance_ip` with your actual proxy and instance IP addresses:

```bash
curl -x http://proxy_ip:port http://instance_ip
```

This command should return a response from the instance, confirming that the proxy is correctly routing your requests.

## Adding Self-Signed Certificates

### For macOS

1. Download the self-signed certificate.
2. Open `Keychain Access` and import the certificate.
3. Ensure the certificate is added by searching for the proxy IP.
4. Set the certificate to `Always Trust`.

### For Windows

1. Download the self-signed certificate.
2. Open `Manage User Certificates` by typing it in the Windows search bar.
3. Import the certificate into the `Trusted Root Certification Authorities` store.
4. Confirm that the certificate is listed and trusted.

<Callout type="info">
	{' '}
	Please confirm with your IT Administrator to ensure you trust the right certificate.
</Callout>

When adding self-signed certificates, try making a `curl` request routed through the HTTPS proxy to check if the computer uses the self-signed certificate. Your request will look something like:

```bash
curl -x https://proxy_ip https://destination_ip
```

### Additional Support

Please get in touch with the Cody support team if you need further assistance with proxy configurations, especially for special enterprise setups. They can provide guidance tailored to your specific network environment.
