customer-service-btnContact Service
HometoOthertoArticle Details

Linux Proxy Setup Guide: How to Configure Proxy IPs

Linux Proxy Setup Guide: How to Configure Proxy IPsDaniel Wong
dateTime2026-05-27 17:15
dateTimeOther

In the development and operations of Linux systems, properly configuring Proxy IP is an essential foundation for ensuring stable network access.

Whether for cross-regional network access, data scraping, or daily development and debugging, mastering proxy configuration methods in Linux can effectively improve network utilization efficiency.

This article will systematically introduce common proxy configuration methods in Linux environments, including temporary proxies, persistent proxies, and proxy settings for frequently used tools.

Proxy Configuration Guide: How to Configure Proxy IP in Linux Systems

Introduction to Common Proxy Protocols

Before starting the configuration, it is recommended to understand the differences between common proxy protocols.

HTTP Proxy: Mainly used for HTTP/HTTPS website access. When accessing HTTPS websites, most proxy services actually use HTTP CONNECT tunnel forwarding.

SOCKS5 Proxy: A more versatile proxy protocol that supports various network traffic types, including TCP/UDP, and features authentication support. Therefore, it is highly common in data scraping and cross-regional network access scenarios.


Temporary Proxy Configuration (Valid for Current Terminal)

If you only need to temporarily download files, update software packages, or debug scripts, you can directly configure proxy environment variables using the export command.

To ensure compatibility with various programming languages and command-line tools, it is generally recommended to configure both lowercase and uppercase variables.

⚠️ Note on Protocol Prefix:

Even if you are accessing an HTTPS website, since most proxies utilize an HTTP CONNECT tunnel, the value of https_proxy should typically still use the http:// prefix.

Mistakenly writing it as https:// can easily trigger SSL handshake version mismatch errors.

export http_proxy="http://Proxy_IP:Port"
export https_proxy="http://Proxy_IP:Port"
export HTTP_PROXY="http://Proxy_IP:Port"
export HTTPS_PROXY="http://Proxy_IP:Port"

Proxy Configuration with Username and Password

export http_proxy="http://Username:Password@Proxy_IP:Port"
export https_proxy="http://Username:Password@Proxy_IP:Port"

If the password contains special characters such as @, :, or /, they must be URL encoded beforehand.

Configuring Proxy Bypass Whitelist (Bypassing Local/LAN)

To prevent local network or internal cluster traffic from erroneously routing through the proxy and causing disconnection, configuring no_proxy is highly recommended. For optimal compatibility, please use the pure domain suffix format without a leading dot:

export no_proxy="localhost,127.0.0.1,internal.net,example.com"
export NO_PROXY="localhost,127.0.0.1,internal.net,example.com"

Unsetting Proxy

unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY no_proxy NO_PROXY

Persistent Proxy Configuration

If you want the proxy settings to remain valid after a system reboot or opening a new terminal session, you need to append the configuration to your Shell profile file.

User-Level Configuration (Recommended)

Bash users typically modify ~/.bashrc, while Zsh users modify ~/.zshrc. Editing the corresponding configuration file manually is more stable and reliable:

# Open the corresponding configuration file based on your active Shell:
nano ~/.bashrc  # If using Bash
nano ~/.zshrc   # If using Zsh

Append the following lines to the end of the file:

export http_proxy="http://Proxy_IP:Port"
export https_proxy="http://Proxy_IP:Port"
export HTTP_PROXY="http://Proxy_IP:Port"
export HTTPS_PROXY="http://Proxy_IP:Port"
export no_proxy="localhost,127.0.0.1,internal.net"
export NO_PROXY="localhost,127.0.0.1,internal.net"

Save the file and run the corresponding command to make the configuration take effect immediately:

source ~/.bashrc  # Or source ~/.zshrc

System-Wide Configuration

If you need all system users to use the proxy, it is recommended to create an independent script in the /etc/profile.d/ directory:

sudo nano /etc/profile.d/proxy.sh

The file content should be as follows:

export http_proxy="http://Proxy_IP:Port"
export https_proxy="http://Proxy_IP:Port"
export HTTP_PROXY="http://Proxy_IP:Port"
export HTTPS_PROXY="http://Proxy_IP:Port"
export no_proxy="localhost,127.0.0.1,internal.net"
export NO_PROXY="localhost,127.0.0.1,internal.net"

To make it take effect in the current terminal immediately, run:

source /etc/profile.d/proxy.sh

⚠️ Troubleshooting Guide: If you modify the /etc/environment file, please do not include the export keyword, as this file only supports pure key-value pairs (e.g., http_proxy="http://Proxy_IP:Port"). Writing Shell syntax here will cause global environment variable initialization anomalies.


Proxy Configuration for Common Tools

Some Linux tools do not automatically read system environment variables, so their internal proxy parameters need to be configured separately.

ToolConfig Path / CommandConfiguration Content
APT (Ubuntu/Debian)/etc/apt/apt.conf.d/99proxyAcquire::http::Proxy "http://Proxy_IP:Port";
Acquire::https::Proxy "http://Proxy_IP:Port";
YUM (CentOS/RHEL)/etc/yum.confproxy=http://Proxy_IP:Port
GitGlobal Command Line Configgit config --global http.proxy http://Proxy_IP:Port
git config --global https.proxy http://Proxy_IP:Port
*Note: This configuration only applies to HTTP/HTTPS protocol repositories. If using an SSH protocol repository (e.g., git@github.com), you need to configure ~/.ssh/config separately.
Wget~/.wgetrc or /etc/wgetrchttp_proxy = http://Proxy_IP:Port
https_proxy = http://Proxy_IP:Port

Frequently Asked Questions (FAQ)

Q1: Why do some programs still connect directly despite the proxy configuration?

Not all programs automatically read the http_proxy environment variable. Certain background services, proprietary software (such as specific Go/Java applications), or browsers require you to specify the proxy address explicitly in their own configuration files or startup parameters.

Q2: What should I do if the proxy connection fails or is too slow?

It is recommended to check the following in sequence:

whether the proxy IP and port are entered correctly, whether the username and password are valid, whether local firewalls (e.g., iptables / ufw) are blocking outbound traffic, and whether the proxy service restricts the number of concurrent connections per single IP address.


To obtain high-anonymity, low-latency enterprise-grade global proxy resources for professional scenarios such as cross-border e-commerce, ad verification, or high-concurrency data collection, feel free to visit the IPDeep Official Website for more professional support.

This article was originally created or compiled and published by Daniel Wong; please indicate the source when reprinting. ( )
ad2