There can be certain reasons a software developer may need to reach out to an HTTP Request using a Proxy Server, to name a few,
- For Testing or Debugging an API.
- To Bypass the Load Balancer.
- To Bypass the Network Restrictions
In such a case, we can make use of the -x option along with a cURL request. When the -x flag is used the request to the HTTP request is executed via the proxy server which acts as an intermediary server between the client and the website server.
Syntax:
curl -x <proxy_protocol>://<proxy_host>:<proxy_port> URL
Option/Parameter | Description | Example |
---|---|---|
curl | The command-line tool used to make HTTP/HTTPS/FTP/SFTP requests. |
|
-x | The option to specify a proxy server. |
|
<proxy_protocol> | The protocol used by the proxy server, such as http , https , socks4 , or socks5 . | http/https |
<proxy_host> | The hostname or IP address of the proxy server. | proxy.example.com/192.168.1.101 |
<proxy_port> | The port number on which the proxy server is listening for incoming connections. | 8080 |
URL | The URL of the resource you want to access through the proxy. | https://code2care.org |
Example: cURL -x HTTPS Proxy
curl -x http://192.168.0.101:8080 https://code2care.org/home
![Curl -X Proxy HTTP Example Curl -X Proxy HTTP Example](https://code2care.org/q/curl--x-option-http-proxy-server-examples/images/Curl -X Proxy HTTP Example.jpg)
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to cURL,
- cURL Option to show HTTP Response Status Code
- URL Encode cURL HTTP GET\POST Data with Examples
- Capture cURL Request Output to a File
- Fix: Curl No Match Found Error
- trurl: A new command-line tool for URL parsing and manipulation by cURL Developer
- Send JSON Data as Payload using cURL HTTP POST Request
- cURL: Show Request and Response Headers
- Get cURL command from Chrome Inspect Network HTTP URL
- Save cURL Command Output to a external file
- cURL DELETE Request with Examples
- How to URL Encode Data for a cURL Request Parameters
- cURL Example using IP (IPv4 and IPv6) address and Port
- How to convert a Postman request to cURL Command
- [fix] command not found curl
- How to Pretty Print cURL JSON Output in Terminal
- How to follow redirects in cURL Command Request
- How to pass authorization header using cURL
- cURL -x Use of HTTP Proxy Server Examples
- Downloading Google Chrome using cURL Command
- How to get cURL Command to run in verbose mode?
- List of 28 Protocols supported by cURL with Examples
- Hide cURL Outputs and Errors on Terminal
- cURL -d Option with Examples
- How to show SSL Certificate details using cURL Command
- Perform Basic Authentication using cURL with Examples
More Posts:
- The default interactive shell is now zsh. [macOS] - MacOS
- Elegant CSS Box Shadows Ideas - CSS
- How to Clear StringJoiner in Java 8 - Java
- How to know the Docker Engine Version - Docker
- git command to remove/unstage files from staging area - Git
- MySQL : Error :1004 SQLSTATE: HY000 (ER_CANT_CREATE_FILE) Can't create file - MySQL
- Python: Pandas Merge Indicator (Left, Right and Both) Example - Python
- Batch updates + Prepared Statement with Spring Boot 3 + JDBC - Java