新配置一台服务器,很多环境都要联网配置,使用W3m网页登录校园网中间坑比较多,写个脚本登录校园网又比较麻烦,于是在网上找了方法使用代理上网
网上看了很多方法,均试一下linux服务器上怎么使用配置文件,配置proxy,但对windows主机的配置介绍的很少。费了很长时间才找到方法,记录一下。
如上外网,则需要走代理
推荐使用的代理软件:ccproxy 注:windows配置端口方法
#!/bin/sh
unset proxyserveraddr unset proxyserverport unset HTTP_PROXY unset HTTPS_PROXY unset FTP_PROXY unset SOCKS_PROXY unset NO_PROXY unset http_proxy unset https_proxy unset ftp_proxy unset socks_proxy unset no_proxy gsettings reset org.gnome.system.proxy ignore-hosts echo -n ""|sudo tee /etc/apt/apt.conf#打开profile文件
vim /etc/profile#添加Proxy代理信息(其中username和password根据需要填写,若无则不填写)
http_proxy = http://username:password@proxy_ip:port/ https_proxy = http://username:password@proxy_ip:port/ ftp_proxy = http://username:password@proxy_ip:port/ export http_proxy export https_proxy export ftp_proxy#生效配置
source /etc/profile例如:
vim /etc/profile http_proxy=http://192.168.1.101:1085 https_proxy=http://192.168.1.101:1085 ftp_proxy=http://192.168.1.101:1085 export http_proxy export https_proxy export ftp_proxy source /etc/profile#添加Proxy代理信息
proxy = http://username:password@proxy_ip:port/ proxy= http://172.31.176.3:1085#打开/wgetrc文件
vim /etc/wgetrc#修改Proxy代理信息
http_proxy=http://username:password@proxy_ip:port/ ftp_proxy=http://username:password@proxy_ip:port/ http_proxy= http://172.31.176.3:1085 ftp_proxy= http://172.31.176.3:1085代理服务器需要鉴权配置
git config --global https.proxy http://172.31.176.3:1085 git config --global http.proxy http://172.31.176.3:1085 git config --global https.proxy https://username:password@proxy.baidu.com:8080 git config --global https.proxy http://127.0.0.1:1080 git config --global https.proxy https://127.0.0.1:1080 git config --global --unset http.proxy git config --global --unset https.proxy npm config delete proxy代理服务器不需要鉴权配置
git config --global https.proxy https://proxy.baidu.com:8080代理 /etc/environment 设定网络代理(非必须) 通常情况下访问国外网站速度都会很慢,推荐设定代理。
vim /etc/environment export http_proxy=xxx export https_proxy=xxx docker systemctl stop docker vim /lib/systemd/system/docker.service