A proxy server allows redirecting requests so that remote resources you are accessing will perceive you based on the proxy server’s details, not your internet provider's.
A proxy server provides more privacy since you are effectively behind it, making all requests through it. Additionally, you can use it if your IP addresses are blocked on the remote host. When making requests via wget or curl, the remote host will see the IP address of the proxy server. This method is especially effective for solving issues related to blocking entire countries' IP address pools.
1. Checking Proxy Settings
echo $http_proxy
echo $https_proxy
echo $ftp_proxy
echo $rsync_proxy
1.1 Alternative Check Method
env | grep -i proxy
If either method returns nothing, it means the proxy server is not configured. If a proxy server is configured, the configuration will be displayed.
2. Enabling Proxy Server
2.1 For a Proxy Without Authentication
export http_proxy=http://Proxy:Port/
2.2 For a Proxy With Authentication
export http_proxy=http://User:Pass@Proxy:Port/
- http_proxy: Type of proxy server (in this example, using the HTTP protocol).
- Proxy: Domain or IP address of the proxy server.
- Port: Port of the proxy server, typically 3128 or 8080.
- User: Username.
- Pass: Password.
2.3 Possible Proxy Types
- http_proxy: A proxy working with the HTTP protocol, which may also handle HTTPS requests if configured.
- `https_proxy: A proxy working with the HTTPS protocol.
- rsync_proxy: A proxy for the rsync protocol used for backup and synchronization.
- ftp_proxy: A proxy configured for the FTP protocol.
You can configure separate proxy servers for each protocol or use the same one if it supports multiple protocols.
3. Configuring Exclusions
To exclude certain addresses from being routed through the proxy server, use the following example:
export no_proxy="localhost,127.0.0.1,.domain.com"
4. Disabling Proxy Settings
Sometimes you may need to disable the proxy after performing a request or downloading something through it and return to normal settings:
unset http_proxy
unset https_proxy
unset rsync_proxy
unset ftp_proxy
5. YUM Package Manager
The proxy server configured above will work with standard commands like wget and curl. If you need to install or update packages using yum, you need to configure it separately by adding the following to the /etc/yum.conf configuration file:
[main]
...
proxy=http://User:Pass@Proxy:Port/
...
# This is the default; if you increase this, yum won't see if the metadata changes
Note that the proxy server settings for the yum package manager must be configured separately.
Final Notes
Proxy server settings take effect immediately without requiring a reboot. However, after a system restart, the commands from section 2 need to be executed again or saved in the /etc/environment or .bashrc file.