Add NO_PROXY support for corporate firewall environments#350
Conversation
Co-authored-by: zereight <42544600+zereight@users.noreply.github.com>
Co-authored-by: zereight <42544600+zereight@users.noreply.github.com>
Co-authored-by: zereight <42544600+zereight@users.noreply.github.com>
Co-authored-by: zereight <42544600+zereight@users.noreply.github.com>
|
Simple unset HTTP_PROXY and HTTPS_PROXY will solve the problem. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Adds NO_PROXY support so the server can bypass configured HTTP(S) proxies for self-hosted/corporate GitLab hosts while still using proxies for external requests.
Changes:
- Implemented
noProxyoption andshouldBypassProxy()matching inGitLabClientPool, and skip proxy agent creation when matched. - Plumbed
NO_PROXY/--no-proxyfromindex.tsinto the client pool. - Added unit + integration tests and documented the new env/CLI options in
README.md.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
gitlab-client-pool.ts |
Adds noProxy support and bypass logic during agent creation. |
index.ts |
Reads NO_PROXY config and passes it to GitLabClientPool. |
README.md |
Documents HTTP_PROXY / HTTPS_PROXY / NO_PROXY usage and patterns. |
test/no-proxy-test.ts |
New NO_PROXY pattern-matching unit tests for agent selection. |
test/no-proxy-integration-test.ts |
New integration tests validating bypass vs proxy usage with mock servers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Handle port-specific patterns (e.g., "example.com:8080") | ||
| const [patternHost, patternPort] = pattern.split(':'); | ||
|
|
||
| // If pattern specifies a port, check if it matches | ||
| if (patternPort && port !== patternPort) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
shouldBypassProxy() parses NO_PROXY entries with pattern.split(':'), which breaks IPv6 literals (e.g., ::1) and bracketed IPv6+port forms (e.g., [::1]:443). This will cause proxy bypass to fail for IPv6 hosts. Consider parsing port by taking the last : only when the suffix is a numeric port and the host is not an IPv6 literal (or explicitly support [v6]:port syntax).
| /** | ||
| * NO_PROXY Test Suite | ||
| * Tests NO_PROXY pattern matching and proxy bypass functionality | ||
| */ | ||
|
|
||
| import { describe, test } from 'node:test'; | ||
| import assert from 'node:assert'; | ||
| import { GitLabClientPool } from '../gitlab-client-pool.js'; |
There was a problem hiding this comment.
These new NO_PROXY unit tests are not currently executed by npm test/npm run test:mock (the test script enumerates specific files). Unless they’re wired into the test scripts, they won’t prevent regressions in CI. Consider adding this file (and the integration test) to the test:mock script or switching to a glob-based tsx --test test/**/*.ts approach.
| /** | ||
| * NO_PROXY Integration Test | ||
| * Tests NO_PROXY functionality with mock servers | ||
| */ | ||
|
|
||
| import { describe, test, after, before } from 'node:test'; | ||
| import assert from 'node:assert'; | ||
| import { | ||
| launchServer, | ||
| findAvailablePort, | ||
| cleanupServers, | ||
| ServerInstance, | ||
| TransportMode, | ||
| HOST | ||
| } from './utils/server-launcher.js'; | ||
| import { MockGitLabServer, findMockServerPort } from './utils/mock-gitlab-server.js'; | ||
| import { CustomHeaderClient } from './clients/custom-header-client.js'; | ||
|
|
There was a problem hiding this comment.
This integration test file is not included in the current test:mock/test:all scripts (which run a fixed list of test files). If it’s meant to be part of the automated suite, it should be added to the test scripts; otherwise it’s easy for NO_PROXY behavior to regress without detection.
HTTP_PROXY/HTTPS_PROXY were supported but NO_PROXY was not, preventing bypass of proxy for self-hosted GitLab instances.
Changes
Core Implementation
shouldBypassProxy()ingitlab-client-pool.tswith standard pattern matching:localhost,192.168.1.1).internal.com)example.com:443)*)createAgentsForUrl()to skip proxy agent creation when host matches NO_PROXY patternsnoProxyparameter toGitLabClientPoolOptionsinterfaceConfiguration
NO_PROXY--no-proxygetConfig()inindex.tstoGitLabClientPoolconstructorUsage
{ "env": { "HTTP_PROXY": "http://proxy.corp.com:8080", "HTTPS_PROXY": "http://proxy.corp.com:8080", "NO_PROXY": "localhost,127.0.0.1,.internal.com,gitlab.mycompany.com" } }Requests to
gitlab.mycompany.combypass proxy while external requests use it.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
nonexistent-proxy.example.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/gitlab-mcp/gitlab-mcp/build/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.