feat: Add https proxying

This commit is contained in:
2025-04-23 17:33:23 +10:00
parent aa3da9d5c3
commit 92f4f19d32
3 changed files with 303 additions and 17 deletions

View File

@@ -52,6 +52,34 @@ curl -v --proxy http://localhost:8080 http://example.com/
curl -v --proxy http://localhost:8080 https://example.com/
```
### HTTPS Support
The proxy now correctly supports HTTPS connections through the HTTP CONNECT method. When using HTTPS:
1. The browser establishes a tunnel through the proxy to the destination server
2. The proxy resolves the hostname using DoH
3. All traffic is forwarded between the client and server without modification
For secure browsing, you must:
- Configure your browser to trust the connection (you may see certificate warnings)
- Make sure your proxy settings are applied to both HTTP and HTTPS traffic
### Verifying HTTPS Support
To verify HTTPS support is working:
1. Configure your browser to use the proxy
2. Visit an HTTPS site like https://example.com
3. Check the proxy logs for CONNECT requests
4. You should see messages like:
```
Proxying request to: example.com (port 443)
DoH response received, size: XXX bytes
Resolved example.com to XXX.XXX.XXX.XXX
```
If you see certificate warnings, this is normal - your browser is correctly verifying the security of the connection.
## Verifying DoH Functionality
To verify that your proxy is using the DoH server for DNS resolution:
@@ -69,6 +97,25 @@ To verify that your proxy is using the DoH server for DNS resolution:
2. **DNS resolution failures**: Check your internet connection and access to hnsdoh.com
3. **Memory leaks**: For long-running tests, monitor memory usage to ensure proper cleanup
## HTTP and HTTPS Troubleshooting
If only HTTPS or only HTTP is working:
### HTTP Issues
- Ensure correct Host header extraction in HTTP requests
- Try a simple curl command: `curl -v --proxy http://localhost:8080 http://example.com/`
- Check proxy logs for any HTTP-specific errors
- Verify that the proxy correctly forwards the entire HTTP request, including all headers
### HTTPS Issues
- HTTPS uses the CONNECT method which creates a tunnel without modifying content
- Try a simple curl command: `curl -v --proxy http://localhost:8080 https://example.com/`
- Certificate warnings are expected and don't indicate proxy failure
- Ensure your browser's security settings allow connecting through the proxy
### Common Fix for Both
If either HTTP or HTTPS isn't working, you can restart the proxy server and try again with verbose logging enabled.
### Using Network Monitoring Tools
You can use tools like Wireshark to monitor the traffic: