Configuring your applications to connect via a proxy server allows you to access services behind a firewall or in a private network. You can also use it to mask your IP address, and if the proxy server provides caching, it could also speed up your access to specific resources.

Some popular programs that provide proxy capabilities are Squid, OpenSSH, and PuTTY. Programs can be configured to use these proxies using the HTTP, HTTPS, or SOCKS(4/5) protocols. These, on the other hand, are commonly used to proxy HTTP and HTTPS traffic.

Most applications require specific configurations to utilize proxy servers. However, some Linux (including macOS and other Unix variants) terminal applications can use environment variable configuration to route HTTP and HTTPS traffic through a proxy without configuring these applications individually.

Steps to use HTTP and HTTPS proxy for Linux terminal applications:

  1. Configure a proxy server if you don't already have one.
  2. Launch terminal.
  3. Check if your terminal application currently uses any proxy server for HTTP or HTTPS traffic (optional).
    $ curl
      "ip": "",
      "city": "Boston",
      "region": "Massachusetts",
      "country": "US",
      "loc": "42.3584,-71.0598",
      "org": "AS6984 Verizon Data Services LLC",
      "postal": "02108",
      "timezone": "America/New_York",
      "readme": ""

    For connection to the Internet, the output should display the gateway's IP address details.

    Example of supported tools are curl, wget, ftp, ssh, yum and apt.

  4. Check if any HTTP or HTTPS proxy is currently set for the current terminal session.
    $ echo $http_proxy $https_proxy $HTTP_PROXY $HTTPS_PROXY

    No proxy if set if the command returns empty output

    http_proxy and https_proxy are the standard though HTTP_PROXY and HTTPS_PROXY are also commonly used. There's also ftp_proxy environment variable that you can use to route your FTP traffic through a proxy.

  5. Set http_proxy or https_proxy environment variable for current terminal session.
    $ export https_proxy=username:password@

    Format as the followings:


    Omit username and password if not required, like so:

    $ export https_proxy=

    Some supported proxy server protocols are http, https, socks4 and socks5

    Configure http_proxy environment variable to route HTTP traffic trough a proxy and configure https_proxy for HTTPS traffic.

  6. Set environment variable on every new terminal session for current user (optional).
    $ echo 'export https_proxy=""' >> ~/.bashrc

    ~/.bashrc is a script executed on every new Bash terminal session. ~/.zshrc is the correshponding file for Zsh.

  7. Set environment variable on every new terminal session for all users in the system (optional).
    $ echo 'export https_proxy=""' | sudo tee -a /etc/profile 
  8. Check if environment variable is successfully set.
    $ echo $https_proxy $http_proxy

    Launch new terminal if you were adding the proxy setting in any of the configuration files for the change to take effect.

  9. Test if your application is now connecting via the configured proxy server.
    $ curl
      "ip": "",
      "hostname": "",  "city": "Boardman",
      "region": "Oregon",
      "country": "US",
      "loc": "45.8399,-119.7006",
      "org": "AS16509, Inc.",
      "postal": "97818",
      "timezone": "America/Los_Angeles",
      "readme": ""
  10. Disable HTTP and HTTPS proxy for current terminal session if no longer required.
    $ unset http_proxy https_proxy
Discuss the article:

Comment anonymously. Login not required.