How to configure proxy server in linux step by step
Configuring a proxy server in Linux can be done via graphical user interface (GUI) settings, environment variables for the current or all users, and application-specific configurations for tools like package managers
Method 1: Using the Graphical User Interface (GUI)
Method 1: Using the Graphical User Interface (GUI)
For users of desktop environments like GNOME (used in Ubuntu) or KDE, the easiest method is using the built-in network settings.
- Open Settings: Navigate to your system’s main “Settings” application.
- Go to Network: Find and select the Network section.
- Access Network Proxy: Click on the “Network Proxy” option, typically represented by a gear icon or a dedicated tab.
- Select “Manual”: Change the proxy method from “None” or “Disabled” to “Manual”.
- Enter Proxy Details: Input the proxy server’s IP address (or hostname) and port number for the relevant protocols (HTTP, HTTPS, FTP, SOCKS).
- Apply Settings: The changes are often applied automatically or after you close the window, making the proxy effective system-wide for most applications that respect the desktop environment’s settings.
Proxy-Seller +4
Method 2: Using Environment Variables (Command Line)
This method is useful for server environments or when you need the proxy for terminal applications like curl and wget. Google Docs +2
Temporary Configuration (Current Session Only)
Run these commands in your terminal, replacing the placeholders with your actual proxy details:
bash
export http_proxy="http://[proxy-address]:[port]"
export https_proxy="http://[proxy-address]:[port]"
export ftp_proxy="http://[proxy-address]:[port]"
export no_proxy="localhost,127.0.0.1,::1"
For an authenticated proxy, use the format:
bash
export http_proxy="http://[username]:[password]@[proxy-address]:[port]"
These settings are lost when you close the terminal session. www.putorius.net +1
Permanent Configuration (For a Specific User)
To make the settings persist across sessions, add the above export lines to your shell’s configuration file (commonly ~/.bashrc or ~/.bash_profile). Google Docs
- Open the file in a text editor (e.g.,
nano ~/.bashrc). - Add the
exportlines at the end of the file. - Save and exit the editor.
- Apply the changes by running
source ~/.bashrcor by opening a new terminal session.Serverspace.us +4
Method 3: Configuring Package Managers
Some applications, including package managers like APT and YUM, do not automatically use system-wide environment variables and require separate configuration. Ask Ubuntu
For APT (Debian/Ubuntu)
Create or edit the configuration file in /etc/apt/apt.conf.d/. SYNAY.NET
bash
sudo nano /etc/apt/apt.conf.d/proxy.conf
Add the following lines (adjust for authentication if needed):
Acquire::http::Proxy "http://[proxy-address]:[port]/";
Acquire::https::Proxy "http://[proxy-address]:[port]/";
The changes take effect immediately the next time you use apt. SYNAY.NET
For YUM/DNF (RHEL/CentOS/Fedora)
Edit the main YUM configuration file. RoseHosting
bash
sudo nano /etc/yum.conf
Under the [main] section, add the proxy details:
ini
[main]
proxy=http://[proxy-address]:[port]
# If authentication is required:
proxy_username=[username]
proxy_password=[password]
Save the file to apply the changes. GitHub Pages documentation
Verification
You can verify your proxy settings using a command-line tool like curl to check your public IP address:
bash
curl -I http://google.com
This should show the proxy server’s IP in the response headers if configured correctly.