Setting up a proxy in Linux (Ubuntu/Debian) requires configuring environment variables for the terminal and modifying system-wide configuration files for persistent connectivity. Users can choose between temporary session-based exports for specific tasks or permanent modifications to files like /etc/environment and /etc/apt/apt.conf.d/ to ensure all traffic routes through the proxy server.
Global Environment Variables for Console Access
The most common method for redirecting traffic in a Linux terminal is through environment variables. These variables tell command-line utilities like curl, wget, and git which proxy server to use for outgoing requests. Linux distinguishes between HTTP, HTTPS, and FTP traffic, requiring specific variables for each protocol.
To set a temporary proxy for the current terminal session, use the export command. This is ideal for one-off tasks or when testing a new GProxy residential endpoint. Replace proxy_address and port with your specific credentials:
# Temporary session configuration
export http_proxy="http://username:password@proxy.gproxy.com:8080"
export https_proxy="http://username:password@proxy.gproxy.com:8080"
export ftp_proxy="http://username:password@proxy.gproxy.com:8080"
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
The no_proxy variable is critical. It prevents the system from attempting to use the proxy for local traffic, which would result in connection timeouts when accessing local databases or internal development servers. Always include 127.0.0.1 and localhost in this list.
For a permanent configuration that persists across reboots for a specific user, add these lines to the ~/.bashrc or ~/.profile file. Open the file using a text editor like Nano:
nano ~/.bashrc
Scroll to the end of the file and paste the export commands. After saving (Ctrl+O, Enter) and exiting (Ctrl+X), reload the configuration by running source ~/.bashrc. This ensures that every time you open a new terminal tab, your GProxy settings are automatically applied.

System-Wide Configuration via /etc/environment
While .bashrc works for individual users, server administrators often need a global configuration that applies to all users and system services. The /etc/environment file is the standard location for system-wide environment variables in Debian and Ubuntu.
Unlike script files, /etc/environment is a simple text file consisting of KEY=VALUE pairs. It does not support shell commands like export. To configure it, follow these steps:
- Open the file with root privileges:
sudo nano /etc/environment - Add the proxy strings exactly as shown below:
http_proxy="http://user:pass@host:port/"
https_proxy="http://user:pass@host:port/"
ftp_proxy="http://user:pass@host:port/"
no_proxy="localhost,127.0.0.1"
Note that for changes in /etc/environment to take effect, a full system reboot or a logout/login cycle is usually required. This method is highly effective for headless servers where multiple cron jobs or background processes require consistent internet access through GProxy’s high-uptime nodes.
Configuring the APT Package Manager
The Advanced Package Tool (APT) used by Ubuntu and Debian does not always respect standard environment variables. If you attempt to run sudo apt update without specific APT proxy settings, the connection may fail or bypass the proxy entirely. This is a common security hurdle in restricted corporate environments.
To fix this, create a dedicated configuration file for APT. It is better practice to create a new file in /etc/apt/apt.conf.d/ rather than modifying the main apt.conf file, as this prevents configuration loss during system upgrades.
sudo nano /etc/apt/apt.conf.d/95proxies
Insert the following lines, ensuring each line ends with a semicolon:
Acquire::http::Proxy "http://username:password@proxy.gproxy.com:8080";
Acquire::https::Proxy "http://username:password@proxy.gproxy.com:8080";
If your proxy requires special characters in the password (like @, #, or !), you must URL-encode them. For example, a password of P@ssword becomes P%40ssword. Failure to encode these characters will cause APT to misparse the connection string, leading to authentication errors.

Proxying Specific CLI Tools (Curl, Wget, Git)
Sometimes you only want specific applications to use a proxy. This "selective proxying" is useful for developers who need to test localized content or scrape data using GProxy without affecting the rest of the system's performance.
1. Wget Configuration
Modify the /etc/wgetrc (global) or ~/.wgetrc (local) file. Add these lines to enable proxy support by default for all wget commands:
use_proxy = on
http_proxy = http://username:password@proxy.gproxy.com:8080
https_proxy = http://username:password@proxy.gproxy.com:8080
2. Curl Configuration
For curl, create or edit ~/.curlrc. This is particularly useful for automated scripts that interact with APIs:
proxy = "http://username:password@proxy.gproxy.com:8080"
3. Git Configuration
Developers working with remote repositories can configure Git to use a proxy for clone, push, and pull operations. This is done via the git config command:
git config --global http.proxy http://username:password@proxy.gproxy.com:8080
git config --global https.proxy http://username:password@proxy.gproxy.com:8080
To remove these settings later, use the --unset flag: git config --global --unset http.proxy.
Comparison of Linux Proxy Methods
Choosing the right method depends on your specific use case. The following table compares the four primary approaches discussed in this guide.
| Method | Scope | Persistence | Best Use Case |
|---|---|---|---|
| Export Command | Current Shell Session | Temporary | Testing and one-off tasks |
| ~/.bashrc | Current User | Permanent | Personal development environments |
| /etc/environment | System-wide | Permanent | Production servers and multi-user systems |
| APT Config | Package Manager only | Permanent | System updates in restricted networks |
Advanced: Using Proxychains for Non-Proxy Aware Apps
Some older Linux applications or custom scripts do not support proxy settings natively. In these cases, proxychains4 is an invaluable tool. It "forces" any TCP connection made by a given application to follow a proxy (HTTP, SOCKS4, or SOCKS5).
First, install the package:
sudo apt update && sudo apt install proxychains4 -y
Edit the configuration file at /etc/proxychains4.conf. Scroll to the bottom and add your GProxy details. Ensure you comment out the default socks4 127.0.0.1 9050 line:
[ProxyList]
# protocol host port username password
http proxy.gproxy.com 8080 username password
To run any application through the proxy, simply prefix the command with proxychains4. For example: proxychains4 telnet example.com or proxychains4 python3 scraper.py. This method is highly effective for bypasses where standard environment variables fail.
Verifying Your Connection
After configuration, it is vital to verify that your traffic is actually routing through the proxy. Use the following Python-based approach or a simple curl command to check your external IP address.
import requests
# Test script to verify proxy connectivity
proxies = {
"http": "http://username:password@proxy.gproxy.com:8080",
"https": "http://username:password@proxy.gproxy.com:8080",
}
try:
response = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=10)
print(f"Current External IP: {response.json()['ip']}")
except Exception as e:
print(f"Connection failed: {e}")
If you are using the console method, run: curl -L https://api.ipify.org. The output should match the IP address of your GProxy server, not your local ISP's IP. If the IP has not changed, check for typos in your configuration files or ensure that your firewall (ufw or iptables) is not blocking the proxy port.
Key Takeaways
Configuring a proxy on Ubuntu or Debian is a multi-layered process. While environment variables handle most terminal tasks, specific tools like APT and Git require dedicated configuration for optimal performance. By using GProxy's stable infrastructure, you can ensure high-speed data retrieval and anonymity across all Linux-based workflows.
- Use ~/.bashrc for personal use: It is the safest and most flexible way to manage proxies for daily terminal work.
- Don't forget APT: System updates will fail on restricted networks unless
/etc/apt/apt.conf.d/is properly configured. - URL Encode Credentials: If your GProxy password contains special characters, always encode them (e.g., # to %23) to avoid syntax errors in configuration files.
- Leverage Proxychains: For applications that refuse to recognize environment variables,
proxychains4provides a reliable "forced" routing solution.
Lesen Sie auch
How to Set Up a Proxy on Your Home Router for the Entire Wi-Fi Network
Manual Proxy Setup in macOS: Step-by-Step Guide
Proxy Setup in Windows 11: A Complete Guide for Users
Troubleshooting Proxy Issues in Multilogin and GoLogin: Common Errors
GoLogin: How to Effectively Configure Proxies for Each Profile
