Ubuntu Server behind Proxy / Firewall

Ubuntu Server behind Proxy / Firewall

Make your environment aware of the local proxy

sudo nano /etc/environment

Add the following three lines to the environment file.

http_proxy=http://127.0.0.1:3128
https_proxy=http://127.0.0.1:3128
ftp_proxy=http://127.0.0.1:3128

apt-get

sudo nano /etc/apt/apt.conf.d/proxy

Add the following three lines to the proxy file.

Acquire::http::Proxy “http://127.0.0.1:3128/”;
Acquire::https::Proxy “http://127.0.0.1:3128/”;
Acquire::ftp::Proxy “http://127.0.0.1:3128/”;

WGET

Configuring the wgetrc file

Like most of the applications wget has a configuration file too – wgetrc:

/etc/wgetrc
~/.wgetrc

 

nano ~/.wgetrc

Now, add the following statement in the file

http://127.0.0.1:3128        (http://proxy-ip:port)

 

sudo nano /etc/wgetrc

# You can set the default proxies for Wget to use for http, https, and ftp.
# They will override the value in the environment.
#https_proxy = http://proxy.yoyodyne.com:18023/
#http_proxy = http://proxy.yoyodyne.com:18023/
#ftp_proxy = http://proxy.yoyodyne.com:18023/

# If you do not want to use proxy at all, set this to off.
#use_proxy = on

 

CURL

create the file (if it does not exist) :

~/.curlrc

sudo nano ~/.curlrc

add the line:

proxy = <proxy_host>:<proxy_port>

GPG KEY ADD

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 7F0CEB10

OR

Save the key to a text file some.key and import it with

cat some.key | sudo apt-key add -

 

ADD-APT-REPOSITORY

Set the variable https_proxy to your proxy

Edit /etc/sudoers or the correct file in /etc/sudoers.d/ so it contains:

sudo nano /etc/sudoers

Add the line:

Defaults env_keep = https_proxy

 

PHP PEAR

sudo pear config-set http_proxy http://127.0.0.1:3128        (http://proxy-ip:port)

 

RUBY GEM INSTALL

sudo gem install –http-proxy http://127.0.0.1:3128 bundler    (http://proxy-ip:port) (bundler = the name of the gem)

 

BUNDLER

sudo -E bundle install

Bình luận về bài viết này