Updated on 2023-05-22 GMT+08:00

Configuring the HTTP Proxy

When you use KooCLI to manage and access cloud resources, cloud service APIs may fail to be called due to the intranet access restriction of your company. In this case, you can use the HTTP proxy by configuring the environment variables http_proxy and https_proxy.

Configuring the Environment Variable http_proxy

Run the command that matches your OS, to configure the environment variable http_proxy.

  • Linux or macOS
    • Temporary environment variable
      Run the following command to configure http_proxy:
      export http_proxy="http://username:password@proxyServer:port"

      In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

      export http_proxy="http://proxyServer:port"
    • Permanent environment variable
      To permanently configure http_proxy in an environment variable that takes effect only for the current user, add the following content to the ~/.bashrc file:
      export http_proxy="http://username:password@proxyServer:port"

      In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

      export http_proxy="http://proxyServer:port"

      After configuring the permanent environment variable, log out and log in again for the variable to take effect.

  • Windows
    • Using Command Prompt
      • Temporary environment variable
        Run the following command to configure http_proxy:
        set http_proxy=http://username:password@proxyServer:port
        In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:
        set http_proxy=http://proxyServer:port
      • Permanent environment variable
        Run the following command to permanently configure http_proxy in an environment variable that takes effect only for the current user:
        setx "http_proxy" "http://username:password@proxyServer:port"

        In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

        setx "http_proxy" "http://proxyServer:port"

        The permanent environment variable will take effect on the clients opened later.

    • Using PowerShell
      • Temporary environment variable
        Run the following command to configure http_proxy:
        $env:http_proxy="http://username:password@proxyServer:port"
        In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:
        $env:http_proxy="http://proxyServer:port"
      • Permanent environment variable
        Run the following command to permanently configure http_proxy in an environment variable that takes effect only for the current user:
        [environment]::SetEnvironmentvariable("http_proxy", "http://username:password@proxyServer:port", "User")

        In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

        [environment]::SetEnvironmentvariable("http_proxy", "http://proxyServer:port", "User")

        The permanent environment variable will take effect on the clients opened later.

Configuring the Environment Variable https_proxy

Run the command that matches your OS, to configure the environment variable https_proxy.

  • Linux or macOS
    • Temporary environment variable
      Run the following command to configure https_proxy:
      export https_proxy="https://username:password@proxyServer:port"

      In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

      export https_proxy="https://proxyServer:port"
    • Permanent environment variable
      To permanently configure https_proxy in an environment variable that takes effect only for the current user, add the following content to the ~/.bashrc file:
      export https_proxy="https://username:password@proxyServer:port"

      In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

      export https_proxy="https://proxyServer:port"

      After configuring the permanent environment variable, log out and log in again for the variable to take effect.

  • Windows
    • Using Command Prompt
      • Temporary environment variable
        Run the following command to configure https_proxy:
        set https_proxy=https://username:password@proxyServer:port

        In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

        set https_proxy=https://proxyServer:port
      • Permanent environment variable
        Run the following command to permanently configure https_proxy in an environment variable that takes effect only for the current user:
        setx "https_proxy" "https://username:password@proxyServer:port"

        In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

        setx "https_proxy" "https://proxyServer:port"

        The permanent environment variable will take effect on the clients opened later.

    • Using PowerShell
      • Temporary environment variable
        Run the following command to configure https_proxy:
        $env:https_proxy="https://username:password@proxyServer:port"

        In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

        $env:https_proxy="https://proxyServer:port"
      • Permanent environment variable
        Run the following command to permanently configure https_proxy in an environment variable that takes effect only for the current user:
        [environment]::SetEnvironmentvariable("https_proxy", "https://username:password@proxyServer:port", "User")

        In the preceding command, proxyServer indicates the domain name (if resolvable) or IP address of the proxy server, and port indicates the port number. Enter a username and password if required, or run the following command:

        [environment]::SetEnvironmentvariable("https_proxy", "https://proxyServer:port", "User")

        The permanent environment variable will take effect on the clients opened later.