linux下各种代理的设置
Set up your proxy.
The bellow proxies as follow:
(1) http-proxy: proxy.xxx.com port: 911
(3) socks5-proxy: proxy.xxx.com port: 1080
Set the bash proxy environment value
$ echo "declare -x http_proxy=\"http://proxy-shz.glb.intel.com:911\" declare -x https_proxy=\"http://proxy-shz.glb.intel.com:911\" declare -x no_proxy=\"`hostname`,localhost,127.0.0.1,127.0.1.1,.local,10.238.154.0/24,10.248.2.5,10.239.27.228,172.17.6.9,172.16.0.1,192.168.253.10,192.168.253.11,192.168.253.12,192.168.253.13,192.168.253.14,192.168.253.15,192.168.253.16,192.168.253.17,192.168.253.18,/usr/bin/wpp192.168.253.19,192.168.253.20,192.168.253.21,192.168.253.22,192.168.253.23,192.168.253.24,192.168.253.25,192.168.253.26,192.168.253.27,192.168.253.28,192.168.253.29,192.168.253.30\" declare -x GIT_PROXY_COMMAND=\"/bin/socks-gw\"" >> ~/.bashrc
$ echo "http_proxy=\"http://proxy-mu.intel.com:911/\" socks_proxy=\"socks://proxy.ir.intel.com:1080/\"" >> /etc/environment
Set the proxychains proxy
you can use proxychains to run some application that need to access the internet. Such as ‘tox‘ for Open Stack test.
$ sudo echo ‘socks5 10.7.211.16 1080‘ >> /etc/proxychains.conf $ sudo echo ‘#!/bin/bash sudo https_proxy= http_proxy= HTTP_PROXY= HTTPS_PROXY= proxychains $@ ‘ >> /usr/bin/myproxychains $ sudo chmod a+x /usr/bin/myproxychains
Then you can run tox by:
$ myproxychains tox -e py27
Set the tsocks proxy
$ echo "server = 10.7.211.16 # Server type defaults to 4 so we need to specify it as 5 for this one server_type = 5 # The port defaults to 1080 but I‘ve stated it here for clarity server_port = 1080" >> /etc/tsocks.conf
Set up the pip proxy
$ cp /usr/local/bin/pip /usr/local/bin/pip.org $ echo ‘#!/bin/bash /usr/bin/pip.org --proxy=http://proxy-shz.glb.intel.com:911 $*‘ > /usr/local/bin/pip.proxy $ sudo chmod a+x /usr/local/bin/pip.proxy $ sudo rm /usr/local/bin/pip $ ln -s /usr/local/bin/pip /usr/local/bin/pip.proxy
Set up the git proxy
$ sudo echo ‘#!/bin/bash connect -H "proxy-mu.intel.com:911" -S "proxy.ir.intel.com:1080" $@‘ > /bin/socks-gw $ sudo chmod a+x /bin/socks-gw
$ echo "declare -x GIT_PROXY_COMMAND=\"/bin/socks-gw\"" >> ~/.bashrc
if you hit git review bug error as follow:
taget@taget-2012-Client-Platform:/opt/stack/nova$ git review -d 142975 Cannot query patchset information The following command failed with exit code 255 "ssh -x gerrit query --format=JSON --current-patch-set change:142975" ERROR: You must specify the destination port correctly. usage: connect [-dnhst45] [-p local-port][-R resolve] [-w timeout] [-H proxy-server[:port]] [-S [user@]socks-server[:port]] [-T proxy-server[:port]] [-c telnet-proxy-command] host port ssh_exchange_identification: Connection closed by remote host ==
refer: http://www.mediawiki.org/wiki/Gerrit/git-review#.22Cannot_query_patchset_information.22
or try this:
[global] index-url="http://otccloud06.sc.intel.com/pypi/simple" [easy_install] index-url=http://otccloud06.sc.intel.com/pypi/simple
Set up the ssh proxy
$ sudo echo ‘ProxyCommand socks-gw %h %p‘ >> ~/.ssh/config
maybe some site do not need proxy.
$ cat ~/.ssh/config Host github.com ProxyCommand /usr/local/bin/socks-gw %h %p Host openstack.org ProxyCommand /usr/local/bin/socks-gw %h %p HostName review.openstack.org User shaohefeng Port 29418
$ cat /usr/local/bin/socks-gw #!/bin/bash case $1 in *.intel.com|192.168.*|127.0.*|localhost|10.*) PROXY= # METHOD="-X connect" ;; *) PROXY=‘-H proxy-mu.intel.com:911 -S proxy.ir.intel.com:1080‘ # METHOD="-X 5 -x proxy-mu.intel.com:1080" ;; esac # /bin/nc $METHOD $* connect $PROXY $*
Test:
$ ssh user@localhost $ ssh [email protected] -p 29418
Set up the apt
You can either setup to proxy for apt
$ sudo echo ‘ Acquire::http::proxy "http://proxy-mu.intel.com:911/"; Acquire::socks::proxy "socks://proxy.jf.intel.com:1080/"; ‘ >> /etc/apt/apt.conf
or you can use the local apt mirrors http://linux-ftp.sh.intel.com/pub/mirrors/ubuntu/ by modifying the /etc/apt/sources.list
Set up the openstack pip local source repository
$ wget https://raw.githubusercontent.com/taget/mybin/master/openstack-tools/create_dir.sh $ sed -i -e ‘s/\(^\s\+\)pip/\1myproxychains pip/‘ create_dir.sh $ grep usage -n4 create_dir.sh $ sudo chmod a+x create_dir.sh && sudo mv create_dir.sh /usr/bin/
$ sudo echo ‘[global] # proxy=http://proxy-shz.intel.com:911 index-url=http://127.0.0.1:7799/tmp # index-url=http://pypi.douban.com/simple cache-dir=/home/shhfeng/.pipcache/pip # [install] # use-mirrors = true # index-url=http://pypi.douban.com/simple‘ > ~/.pip/pip.conf $ sudo echo "sudo sed -i -e ‘s/^\s\?\(index-url\)/# \1/‘ ~/.pip/pip.conf" > /usr/bin/en_pip_url $ sudo echo "sudo sed -i -e ‘s/^#\s\?\(index-url\)/\1/‘ /home/shhfeng/.pip/pip.conf" > /usr/bin/dis_pip_url $ sudo chmod a+x /usr/bin/en_pip_url /usr/bin/dis_pip_url
$echo ‘Listen 7799 <VirtualHost *:7799> ServerName localhost DocumentRoot /var/www <Directory /var/www> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/pip_error.log </VirtualHost> ‘ > /etc/apache2/sites-available/pip.conf $ ln -s /etc/apache2/sites-available/pip.conf /etc/apache2/sites-enabled/pip.conf
$ sudo service apache2 restart
$ sudo echo ‘#!/bin/bash for x in `ls /opt/stack/` do if [ -f /opt/stack/$x ]; then continue fi if [ -e "/opt/stack/$x/.git" ]; then create_dir.sh $x fi done‘ > /usr/bin/create_pip $ sudo chmod a+x /usr/bin/create_pip
you can also ref this link: https://www.berrange.com/posts/2014/11/14/faster-rebuilds-for-python-virtualenv-trees/
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。