ProxyMan is a shell script to manage system-wide proxy settings on Linux systems. It supports both Debian/Ubuntu-based (using apt
) and RHEL/CentOS/Fedora-based systems (using dnf
or yum
). In addition, it configures proxies for wget
, Docker (both system daemon and per-user Docker settings), and system-wide environment variables like http_proxy
, https_proxy
, and no_proxy
.
-
Package Manager Support:
Detects your system’s package manager (apt
,dnf
, oryum
) and configures the proxy settings accordingly. -
System-Wide Environment Variables:
Configures/etc/environment
to sethttp_proxy
,https_proxy
,no_proxy
and their uppercase variants globally. -
Wget Proxy Configuration:
Updates/etc/wgetrc
sowget
commands use the configured proxy. -
Docker Proxy Configuration:
- Sets system-wide Docker proxy via
/etc/docker/daemon.json
. - Creates or updates a systemd drop-in file at
/etc/systemd/system/docker.service.d/http-proxy.conf
to allow the Docker daemon to pull images via the proxy. - Configures per-user Docker proxy settings in
~/.docker/config.json
for the user who ransudo
.
- Sets system-wide Docker proxy via
-
Backup and Restore Mechanism:
- When you run
set
, ProxyMan creates backups of all files it modifies, if not already existing. - When you run
unset
, it restores these backups, effectively removing the proxy settings. - When you run
purge
, it removes all proxy settings and all backup files permanently.
- When you run
-
Interactive Mode:
- If
/etc/proxy.conf
does not exist, ProxyMan can prompt you forHTTP_PROXY
,HTTPS_PROXY
, andNO_PROXY
interactively. - Default
NO_PROXY
values cover local IP ranges and docker0 networks, so you don’t have to guess.
- If
-
Shell Integration:
- The
export
command printsexport
statements so you caneval
them to apply proxy vars to your current shell session without reopening it. - The
unexport
command printsunset
statements to remove the proxy vars from your current shell.
- The
-
Safe and User-Friendly:
- Color-coded output helps distinguish success messages (green), prompts/warnings (yellow), and errors (red).
- Before destructive operations like
purge
, it asks for confirmation. - Clear instructions are printed after
set
andunset
so you know the next steps.
-
Run as root (via
sudo
), since system-wide configuration files are modified. -
If you prefer a non-interactive setup, ensure
/etc/proxy.conf
exists with:HTTP_PROXY=http://proxy.example.com:8080 HTTPS_PROXY=http://proxy.example.com:8080 NO_PROXY=localhost,127.0.0.1,::1
Adjust these values to match your actual proxy setup.
If /etc/proxy.conf
is missing, ProxyMan will prompt you interactively to enter these values when you run set
.
- Copy the proxyman.sh script to a location in your $PATH, for example:
sudo cp proxyman.sh /usr/local/bin/proxyman
sudo chmod +x /usr/local/bin/proxyman
- Ensure /etc/proxy.conf is created and contains
HTTP_PROXY
,HTTPS_PROXY
, andNO_PROXY
.
Run all commands with sudo
:
- Set proxy:
sudo proxyman set
This configures all system-wide files, Docker, and per-user Docker config. If /etc/proxy.conf
is missing, it will prompt you interactively. After setting, ProxyMan will print instructions on how to apply these settings to your current shell (using eval "$(sudo proxyman export)"
).
- Unset proxy:
sudo proxyman unset
Restores original configurations from backups and removes proxy settings. After unsetting, it will print instructions on how to remove the settings from your current shell (using eval "$(sudo proxyman unexport)"
).
- List current settings:
sudo proxyman list
Shows the current state of all relevant files.
- Export Commands
Use the following command to print export statements for http_proxy
, https_proxy
, no_proxy
, and their uppercase equivalents:
sudo proxyman export
To apply these proxy settings to your current shell without reopening it, use:
eval "$(sudo proxyman export)"
- Unexport Commands
To print unset statements for removing proxy variables from your current shell:
sudo proxyman unexport
To apply these unset statements, use:
eval "$(sudo proxyman unexport)"
- Help
For help and usage information, use:
sudo proxyman -h
sudo proxyman set
eval "$(sudo proxyman export)"
sudo proxyman unset
eval "$(sudo proxyman unexport)"
Alternatively, you can reopen your terminal session after setting or unsetting proxies to apply or remove the proxy environment.
-
The script attempts to detect your system's package manager:
- If
apt
is found, it configures/etc/apt/apt.conf
. - If
dnf
oryum
is found, it configures those accordingly. - If none of these package managers are found, it skips package manager proxy configuration.
- If
-
Docker Integration:
- Requires Docker 20.10+ for the
proxies
key indaemon.json
. - Creates a systemd drop-in file at
/etc/systemd/system/docker.service.d/http-proxy.conf
to allow the Docker daemon to pull images via the proxy. - Configures per-user Docker settings in
~/.docker/config.json
for the user who invokedsudo
. If run as root, it uses the root user's home directory.
- Requires Docker 20.10+ for the
-
Backup Behavior:
- Backups are created only once. Subsequent runs will not overwrite the backups.