Skip to content

Instantly share code, notes, and snippets.

@gotev
Created June 1, 2016 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotev/fd9400de12f7dbd288e934332bc8be61 to your computer and use it in GitHub Desktop.
Save gotev/fd9400de12f7dbd288e934332bc8be61 to your computer and use it in GitHub Desktop.
Enable system-wise HTTP proxy on debian
#!/bin/bash
# Idea taken from example: https://codepoets.co.uk/2014/debian-http_proxy-setting/
if [[ $EUID -ne 0 ]]; then
echo "This script has to be executed as root" 1>&2
exit 1
fi
if [ $# -ne 2 ]; then
echo "Usage: ./enable-proxy.sh PROXY_IP PROXY_PORT"
exit 2
fi
echo "export http_proxy=http://$1:$2" > /etc/profile.d/proxy.sh
echo "Acquire::http::Proxy \"http://$1:$2\";" > /etc/apt/apt.conf.d/99HttpProxy
echo "http_proxy = http://$1:$2" >> /etc/wgetrc
echo "System-wise proxy set to $1:$2"
@gotev
Copy link
Author

gotev commented Jul 13, 2016

To install a proxy server with squid on CentOS 7 (I assume you have root access):

yum install squid
sed -i 's/http_access deny all/http_access allow all/g' /etc/squid/squid.conf
systemctl start squid
systemctl enable squid

Add this to /etc/sysconfig/iptables:

-A INPUT -p tcp -m tcp --dport 3128 -j ACCEPT

and then execute:

systemctl restart iptables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment