NeuroAgent

How to Configure Proxy Only for GitHub Copilot in VS Code

Detailed guide on configuring proxy exclusively for GitHub Copilot in Visual Studio Code without affecting other traffic. Solving authentication and corporate proxy issues.

How can I configure a proxy specifically for GitHub Copilot in Visual Studio Code without affecting other network traffic?

I’m using VS Code and want to set up a proxy exclusively for the GitHub Copilot extension while leaving all other network activity unchanged. The standard approach of configuring a proxy for the entire VS Code works, but I don’t want to route all editor traffic through the proxy:

json
// settings.json
{
  ...
  "http.proxy": "http://usr:pwd@host:port"
}

I found a potential solution in the Copilot documentation:

json
// settings.json
{
  ...
  "github.copilot.advanced": {
    "debug.overrideProxyUrl": "http://usr:pwd@host:port"
  }
}

However, this configuration doesn’t work: Copilot stops functioning, and no requests from the extension appear in the proxy server (Squid) logs. The setting description “Override GitHub authentication proxy full URL” doesn’t clarify the situation — perhaps additional authentication mechanisms need to be implemented.

How do I properly configure proxying only for GitHub Copilot in VS Code using a regular HTTP/HTTPS proxy?

NeuroAgent

Configuring GitHub Copilot in VS Code to Use a Proxy

GitHub Copilot in VS Code can be configured to use a proxy through the debug.overrideProxyUrl parameter in the extension settings, but proper authentication configuration and proxy verification are often required for correct operation. The main issue is that the extension may ignore proxy settings due to lack of proper authentication handling or due to specifics of working with corporate proxies.

Table of Contents

Checking Current Configuration

Before configuring a proxy specifically for GitHub Copilot, ensure that the extension is properly installed and functioning:

json
// settings.json
{
  "github.copilot.enable": {
    "autoCompletions": true,
    "inlineSuggests": true
  }
}

Important: Verify that the GitHub Copilot extension is working properly without proxy settings. If the extension doesn’t function even without proxy configurations, resolve this issue first.

To diagnose the current state of the extension:

  1. Open the Output panel (View → Output)
  2. Select “GitHub Copilot” from the dropdown list
  3. Check for errors and warnings in the logs

Configuring Proxy for GitHub Copilot

The main VS Code configuration file settings.json supports several approaches to configuring proxy for extensions:

Method 1: Using debug.overrideProxyUrl

json
// settings.json
{
  "github.copilot.advanced": {
    "debug.overrideProxyUrl": "http://username:password@proxy-host:port"
  }
}

Configuration features:

  • URL should be complete, including authentication credentials
  • HTTP and HTTPS proxies are supported
  • Some corporate proxies require additional headers

Method 2: Separate proxy configuration for extensions

VS Code allows configuring proxy for individual components through system environment variables:

bash
# For Linux/macOS
export HTTP_PROXY="http://username:password@proxy-host:port"
export HTTPS_PROXY="http://username:password@proxy-host:port"

# For Windows
set HTTP_PROXY=http://username:password@proxy-host:port
set HTTPS_PROXY=http://username:password@proxy-host:port"

After setting the variables, restart VS Code.

Solving Authentication Problems

The issue with debug.overrideProxyUrl is often related to authentication specifics in corporate networks:

Checking proxy connectivity

Create a test script to verify connectivity:

javascript
// test-proxy.js
const https = require('https');

const options = {
  hostname: 'api.githubcopilot.com',
  port: 443,
  path: '/_/healthz',
  method: 'GET',
  agent: new https.Agent({
    proxy: 'http://username:password@proxy-host:port'
  })
};

const req = https.request(options, (res) => {
  console.log(`statusCode: ${res.statusCode}`);
  res.on('data', d => {
    process.stdout.write(d);
  });
});

req.on('error', (e) => {
  console.error(e);
});

req.end();

Configuring Squid for Copilot

If you’re using Squid, add the following rules for proper Copilot operation:

squid
# squid.conf
acl copilot dstdomain api.githubcopilot.com githubcopilot.localhost
http_access allow copilot

# For authentication
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/htpasswd
auth_param basic realm Squid proxy-caching web server
acl authenticated proxy_auth REQUIRED
http_access allow authenticated

Alternative Proxying Methods

Using system proxy through network settings

  1. Open your operating system’s network settings
  2. Set up a proxy for the current user
  3. Configure exceptions for local addresses

Using Docker for traffic isolation

Create a separate container for working with Copilot:

dockerfile
# Dockerfile
FROM node:18-alpine

ENV HTTP_PROXY=http://username:password@proxy-host:port
ENV HTTPS_PROXY=http://username:password@proxy-host:port

# Install VS Code and Copilot
RUN npm install -g @vscode/vsce
RUN code --install-extension GitHub.copilot

CMD ["code", "--disable-extensions"]

Diagnosis and Debugging

Enabling verbose logging

json
// settings.json
{
  "github.copilot.advanced": {
    "debug.overrideProxyUrl": "http://username:password@proxy-host:port",
    "debug.enable": true,
    "debug.level": "verbose"
  }
}

Checking network requests

Use tools for tracking network requests:

  1. Wireshark - for analyzing all network packets
  2. Fiddler - for intercepting HTTP/HTTPS traffic
  3. Charles Proxy - for debugging proxy connections

Common errors and their solutions

Error Possible Solution
ECONNREFUSED Check proxy server availability
407 Proxy Authentication Required Verify credentials are correct
ETIMEDOUT Check proxy server timeouts
CERT_HAS_EXPIRED Update proxy certificates

Conclusion

Configuring a proxy specifically for GitHub Copilot in VS Code requires a careful approach to authentication configuration and compatibility checking with corporate proxies. Key recommendations:

  1. Start with basic configuration of debug.overrideProxyUrl with a complete URL including authentication
  2. Test proxy functionality with test scripts before applying in VS Code
  3. Use separate configurations for extensions and the main application
  4. Enable verbose logging for troubleshooting problems
  5. Consider alternative proxying methods when encountering difficulties

If standard methods don’t work, you may need to contact GitHub support or your system administrator to configure the corporate proxy server.