cURL SSL Proxy Examples
Complete guide to configuring static outbound SSL proxy connections using cURL. Learn how to use command-line and shell script proxy configurations with SSL verification, authentication, and advanced options.
What is cURL?
cURL is a command-line tool for making HTTP requests through a secure proxy server. It's essential for scripting, automation, testing, and debugging HTTP connections through proxy servers.
Use Case: Perfect for shell scripting, CI/CD pipelines, and automated testing where you need reliable proxy connections with SSL support.
Basic SSL Proxy Configuration
1. Using Environment Variables
Best Practice: This prevents secrets from appearing in your shell history and mirrors the os.environ method used in the Python scripts.
export PROXY_HOST="eu-01.outboundgateway.com"
export PROXY_PORT="8443"
export PROXY_USER="USER"
export PROXY_PASS="PASS"
curl -x "https://${PROXY_USER}:${PROXY_PASS}@${PROXY_HOST}:${PROXY_PORT}" \
"https://outboundgateway.com/ip/"
2. Verbose Debugging
Troubleshooting: Use the -v flag to inspect the SSL handshake details and verify that the proxy connection is encrypted correctly.
curl -v -x "https://USER:PASS@eu-01.outboundgateway.com:8443" \
"https://outboundgateway.com/ip/"
Best Practices
1. Environment Variable Security
Always use environment variables for proxy credentials instead of hardcoding them in commands or scripts.
Why: This prevents secrets from appearing in your shell history (~/.bash_history), makes credential rotation easier, and mirrors the Python documentation's os.environ approach for consistency across your infrastructure.
2. Verbose Debugging
Use curl -v when troubleshooting SSL proxy connections.
Why: The -v flag reveals the SSL handshake process, allowing you to verify that TLS-in-TLS (connecting to an HTTPS proxy to reach an HTTPS site) is working correctly. This is essential for debugging connection issues.
3. HTTPS Proxy URLs
Always use https:// for the proxy URL in the -x flag.
Why: Using https:// ensures the connection from your client to the proxy server is encrypted. This is critical for TLS-in-TLS scenarios where both the proxy connection and the target connection use HTTPS.
4. Timeout Configuration
Set explicit timeouts using --connect-timeout and --max-time.
Why: Proxies can hang or become unresponsive. Explicit timeouts prevent your scripts from hanging indefinitely, ensuring they fail fast and gracefully when infrastructure issues occur.
SSL Proxy Best Practices
1. Use Environment Variables
Store credentials in environment variables instead of hardcoding them in scripts.
2. Set Proper Timeouts
Always set connection and operation timeouts to prevent hanging scripts.
3. Implement Error Handling
Check HTTP response codes and handle errors gracefully in your scripts.
4. Use SSL Verification
Only disable SSL verification for development. Always verify certificates in production.
5. Add Retry Logic
Implement retry mechanisms for transient network failures.
Common Issues and Solutions
Connection Timeouts
Solution: Increase timeout values or check network connectivity to proxy server.
SSL Certificate Verification Failed
Solution: Update CA certificates or provide custom certificate bundle. Use -k only for development.
Authentication Failures
Solution: Verify credentials and ensure proper URL encoding of special characters.
Performance Issues
Solution: Test with different timeout values and check proxy server load.
cURL Command Options Reference
| Option | Description | Example |
|---|---|---|
-x |
Set proxy server | -x http://proxy:8080 |
-k |
Insecure SSL connection (dev only) | -k |
--cacert |
CA certificate file | --cacert /path/to/ca.crt |
--connect-timeout |
Connection timeout in seconds | --connect-timeout 15 |
--max-time |
Maximum operation time in seconds | --max-time 30 |
--proxy-user |
Proxy authentication | --proxy-user user:pass |
--tlsv1.2 |
Force TLS 1.2 | --tlsv1.2 |
-v |
Verbose output | -v |
Ready to Use SSL Proxy with cURL?
Get your static SSL proxy IPs today and start making secure HTTPS connections with consistent IP addresses for your shell scripts and automation tasks.
Get Started with OutboundGatewayRelated SSL Proxy Guides
Python SSL Proxy
Complete Python examples using requests, urllib3, and aiohttp libraries.
View Python Guide →Node.js SSL Proxy
JavaScript/Node.js implementation with axios, fetch, and undici libraries.
View Node.js Guide →PHP SSL Proxy
Web-focused proxy configuration with cURL, Guzzle, and Symfony HTTP Client.
View PHP Guide →📖 Language Comparison: Looking for the best approach? Python offers excellent libraries like requests and aiohttp, while Node.js provides native async support. Java is ideal for enterprise applications, PHP works well for web applications, and cURL is perfect for shell scripting.