Linux 下 让终端使用代理

twitter

操作系统:Manjaro
终端:zsh

➜  ~ curl www.google.com
curl: (7) Failed to connect to www.google.com port 80: 连接超时


  • 安装 polipo
sudo pacman -Ss polipo   # 搜索看看软件库中有没有
sudo pacman -S polipo      # 肯定是有的,安装它
  • 配置 polipo
sudo vim /etc/polipo/config 
  • 在它的末尾添加以下命令,或者去掉以下命令前面的注释符号;若此文件不存在,则自己创建
socksParentProxy = "localhost:1080"
socksProxyType = socks5 
  • 重新启动 polipo 服务
sudo systemctl restart polipo.service
  • 查看状态
sudo systemctl status polipo.service
● polipo.service - Polipo Proxy Server
   Loaded: loaded (/usr/lib/systemd/system/polipo.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-01-24 17:19:55 CST; 2h 27min ago
 Main PID: 2046 (polipo)
    Tasks: 1 (limit: 4915)
   Memory: 504.0K
   CGroup: /system.slice/polipo.service
           └─2046 /usr/bin/polipo

1月 24 17:19:55 TpPc systemd[1]: Started Polipo Proxy Server.
1月 24 17:19:55 TpPc polipo[2046]: DNS: couldn't parse line in /etc/resolv.conf -- skipping.
1月 24 17:19:55 TpPc polipo[2046]: Established listening socket on port 8123.
  • 终端设置代理环境
export http_proxy=http://localhost:8123 
export https_proxy=http://localhost:8123
  • 重启终端后代理环境失效,需要再次设置上面的两条命令


  • 如果想长期生效的那么在 .zshrc 或者 .bashrc 下增加
export https_proxy=http://localhost:8123
export http_proxy=http://localhost:8123 

polipo 的默认端口时 8123


➜  ~ curl www.google.com                     
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en-SG"><head>
....
</html>%   
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一. shell shell是什么?壳?其实就是操作系统包含一个外壳,然后让用户通过这个壳来操作OS,而shell...
    扛支枪阅读 2,763评论 0 2
  • Linux命令学习 记录小白学习Linux的过程。 常用命令 man命令 常用工具命令 man命令是Linux下的...
    吃蘑菇De大灰狼阅读 2,783评论 1 15
  • 官网 中文版本 好的网站 Content-type: text/htmlBASH Section: User ...
    不排版阅读 4,434评论 0 5
  • 作为一个linux使用者,你的终端起码应该是这个样子的(而不是不断的ctrl+alt+t,不断的打开终端)(有关z...
    jockerMe阅读 3,032评论 2 10
  • 己经由2月1号开始休假至今,有18天了,何其奢侈的日子。没工作没饭吃,恐惧属于中年妇女,上有老下有小,与丈夫感情有...
    mandymandymandy阅读 96评论 0 0