• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Use Curl Command with Proxy on Linux

Written by Rahul, Updated on October 10, 2019

Curl is a utility used for data transfer in command lines or scripts. In this tutorial, you will learn how to use the curl command to connect via a proxy server on the Linux system.

Using Environment Variable

In a very simple word, you can simply set the following environment variables on your system. The curl command will automatically use these variables as a proxy. You can export those variables in your shell, like:

Without Authentication 

export http_proxy="http://proxy.server:port"
export https_proxy="https://proxy.server:port"

With Authentication 

export http_proxy="http://username:[email protected]:port"
export https_proxy="https://username:[email protected]:port"

After exporting the environment variables, the curl command will automatically use the above proxy during a remote connection.

curl http://example.com

Once your work is done, you can simply unset these environment variables like:

unset http_proxy
unset https_proxy

Without Environment Variable

Instead of setting environment variables, you can simply pass the proxy details to curl command as a command-line parameter.

curl -x "http://username:[email protected]:port" http://example.com

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy