DNS Override
The --connect-to option allows you to override DNS resolution and route requests to a different host or port. This is useful for testing, debugging, and local development.
Basic Usage
Section titled “Basic Usage”orb --connect-to "example.com:443:localhost:8443" https://example.comFormat: HOST1:PORT1:HOST2:PORT2
This routes requests for example.com:443 to localhost:8443.
How It Works
Section titled “How It Works”- Orb resolves
HOST2to get the actual IP address - Connects to
HOST2:PORT2instead ofHOST1:PORT1 - Sends the request with the original
Host: HOST1header - TLS validation (if any) uses the original hostname
The request URL and Host header remain unchanged - only the network connection is rerouted.
Wildcard Matching
Section titled “Wildcard Matching”Any Host
Section titled “Any Host”Leave HOST1 empty to match any hostname:
orb --connect-to ":443:localhost:8443" https://any-domain.comAny Port
Section titled “Any Port”Leave PORT1 empty to match any port:
orb --connect-to "example.com::localhost:8443" https://example.comorb --connect-to "example.com::localhost:8443" https://example.com:8080Both Wildcards
Section titled “Both Wildcards”orb --connect-to "::localhost:8443" https://anything.com:any-portMultiple Rules
Section titled “Multiple Rules”Use --connect-to multiple times for multiple rules:
orb \ --connect-to "api.prod.example.com:443:localhost:3000" \ --connect-to "auth.prod.example.com:443:localhost:3001" \ https://api.prod.example.comRules are matched in order. First match wins.
Common Use Cases
Section titled “Common Use Cases”Local Development
Section titled “Local Development”Test production URLs against local services:
# Route production API to local serverorb --connect-to "api.example.com:443:localhost:8080" \ https://api.example.com/usersTesting with Different Servers
Section titled “Testing with Different Servers”# Test staging server with production URLorb --connect-to "api.example.com:443:staging.example.com:443" \ https://api.example.com/healthDocker Development
Section titled “Docker Development”# Route to Docker containerorb --connect-to "api.example.com:443:host.docker.internal:8080" \ https://api.example.comLoad Balancer Bypass
Section titled “Load Balancer Bypass”Test a specific backend server:
# Route directly to a specific serverorb --connect-to "api.example.com:443:server-01.internal:443" \ https://api.example.com/healthLocal Mock Server
Section titled “Local Mock Server”Test with a mock server:
# Route to mock serverorb --connect-to "api.example.com:443:127.0.0.1:9999" \ -k \ https://api.example.com/usersWith Verbose Output
Section titled “With Verbose Output”See the override in action:
orb -v --connect-to "example.com:443:localhost:8443" https://example.comOutput:
* Connecting to localhost:8443 (overriden from example.com:443)* Resolving host: localhost* Resolved localhost to 127.0.0.1 (0ms)...TLS Considerations
Section titled “TLS Considerations”When overriding HTTPS connections:
- Certificate validation uses the original hostname (HOST1)
- If the target server has a different certificate, use
-kor provide the correct CA with--cacert
# Local server with production certificateorb --connect-to "api.example.com:443:localhost:8443" \ https://api.example.com
# Local server with self-signed certificateorb --connect-to "api.example.com:443:localhost:8443" \ -k \ https://api.example.com
# Local server with known CAorb --connect-to "api.example.com:443:localhost:8443" \ --cacert local-ca.pem \ https://api.example.com