乐闻世界logo
搜索文章和话题

What protocols does whistle support and how to handle proxying of different protocols?

2月21日 16:26

Answer

Whistle supports proxying multiple protocols including HTTP, HTTPS, WebSocket, HTTP/2, etc., meeting debugging needs for different scenarios.

Supported Protocols

1. HTTP Protocol

Basic proxy:

shell
www.example.com host 127.0.0.1:8080

Forward proxy:

shell
www.example.com forward http://127.0.0.1:8080

Modify request:

shell
www.example.com reqHeaders://{custom-headers.json}

2. HTTPS Protocol

Basic proxy:

shell
www.example.com host 127.0.0.1:8443

Enable HTTPS interception:

shell
pattern whistle.https://

Configure HTTPS certificate:

  1. Download root certificate
  2. Install to system
  3. Enable HTTPS interception

3. WebSocket Protocol

Basic proxy:

shell
ws://example.com host 127.0.0.1:8080 wss://example.com host 127.0.0.1:8080

Forward proxy:

shell
ws://example.com forward ws://127.0.0.1:8080 wss://example.com forward wss://127.0.0.1:8080

WebSocket message capture:

  • Automatically capture connection establishment
  • Record sent and received messages
  • Display connection status

4. HTTP/2 Protocol

Whistle supports HTTP/2 protocol proxying:

  • Automatic downgrade to HTTP/1.1
  • Support for HTTP/2 multiplexing
  • Support for server push

5. SOCKS Proxy

Configure SOCKS proxy:

shell
www.example.com socks://127.0.0.1:1080

SOCKS5 proxy:

shell
www.example.com socks5://127.0.0.1:1080

Protocol Conversion

1. HTTP to HTTPS

Configure rule:

shell
http://www.example.com forward https://www.example.com

2. HTTPS to HTTP

Configure rule:

shell
https://www.example.com forward http://www.example.com

3. WebSocket to HTTP

Configure rule:

shell
ws://example.com forward http://127.0.0.1:8080

Protocol-Specific Configuration

1. HTTP Protocol Configuration

Set request method:

shell
www.example.com method://POST

Set request headers:

shell
www.example.com reqHeaders://{http-headers.json}

Set response headers:

shell
www.example.com resHeaders://{http-headers.json}

2. HTTPS Protocol Configuration

Disable SSL verification:

shell
www.example.com disable://ssl

Set SSL version:

shell
www.example.com ssl://TLSv1.2

Custom CA certificate:

shell
www.example.com ca://{custom-ca.crt}

3. WebSocket Protocol Configuration

Set WebSocket subprotocol:

shell
ws://example.com protocol://chat

Set WebSocket timeout:

shell
ws://example.com timeout://30000

Set WebSocket heartbeat:

shell
ws://example.com ping://30000

Multi-Protocol Scenarios

1. Mixed Protocol Proxy

Proxy HTTP and HTTPS simultaneously:

shell
www.example.com host 127.0.0.1:8080 api.example.com host 127.0.0.1:8080

Proxy WebSocket and HTTP simultaneously:

shell
ws://example.com host 127.0.0.1:8080 www.example.com host 127.0.0.1:8080

2. Protocol Routing

Route by protocol:

shell
# HTTP route to local http://www.example.com host 127.0.0.1:8080 # HTTPS route to test server https://www.example.com host test.example.com # WebSocket route to local ws://www.example.com host 127.0.0.1:8080

3. Protocol Conversion Scenarios

Development uses HTTP, production uses HTTPS:

shell
# Development environment www.example.com forward http://127.0.0.1:3000 # Production environment www.example.com forward https://api.example.com

Protocol Debugging Tips

1. View Protocol Information

In whistle management interface:

  1. Click "Network" tab
  2. Click request to view details
  3. View protocol information in "General" tab

2. Protocol Downgrade Testing

Test HTTP/2 downgrade:

shell
www.example.com disable://h2

Test WebSocket downgrade:

shell
ws://example.com disable://websocket

3. Protocol Performance Testing

Test performance of different protocols:

shell
# HTTP/1.1 www.example.com disable://h2 # HTTP/2 www.example.com enable://h2

Protocol Security

1. HTTPS Security

Enable HTTPS interception:

shell
pattern whistle.https://

Verify certificate:

shell
www.example.com verify://ssl

Disable insecure protocols:

shell
www.example.com disable://ssl3 www.example.com disable://tls1

2. WebSocket Security

Use WSS:

shell
wss://example.com host 127.0.0.1:8080

Verify WebSocket handshake:

shell
ws://example.com verify://websocket

Protocol Compatibility

1. Browser Compatibility

  • Chrome/Edge: Full support for all protocols
  • Firefox: Support for HTTP, HTTPS, WebSocket
  • Safari: Support for HTTP, HTTPS, WebSocket

2. Server Compatibility

  • Nginx: Support for HTTP, HTTPS, WebSocket
  • Apache: Support for HTTP, HTTPS
  • Node.js: Support for all protocols

3. Mobile Compatibility

  • iOS: Support for HTTP, HTTPS, WebSocket
  • Android: Support for HTTP, HTTPS, WebSocket

Protocol Best Practices

1. Development Environment

  • Use HTTP protocol for easier debugging
  • Use WebSocket for real-time communication
  • Disable SSL verification for faster speed

2. Test Environment

  • Use HTTPS to simulate production environment
  • Use WSS to test secure connections
  • Enable SSL verification to ensure security

3. Production Environment

  • Use HTTPS to ensure security
  • Use WSS to protect WebSocket
  • Enable all security verifications

Protocol Troubleshooting

1. HTTPS Connection Failure

Check items:

  • Is certificate correctly installed
  • Do SSL versions match
  • Is firewall blocking

Solution:

shell
www.example.com disable://ssl

2. WebSocket Connection Failure

Check items:

  • Are proxy rules correct
  • Does server support WebSocket
  • Is network stable

Solution:

shell
ws://example.com forward ws://127.0.0.1:8080

3. Protocol Incompatibility

Check items:

  • Client and server protocol versions
  • Browser support
  • Server configuration

Solution:

shell
www.example.com disable://h2
标签:Whistle