<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>终端 &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/%E7%BB%88%E7%AB%AF/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Mon, 27 Apr 2020 17:50:55 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] Mac终端使用Privoxy代理</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-mac%e7%bb%88%e7%ab%af%e4%bd%bf%e7%94%a8privoxy%e4%bb%a3%e7%90%86/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-mac%e7%bb%88%e7%ab%af%e4%bd%bf%e7%94%a8privoxy%e4%bb%a3%e7%90%86/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sat, 27 Oct 2018 05:31:55 +0000</pubDate>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[Privoxy]]></category>
		<category><![CDATA[代理]]></category>
		<category><![CDATA[终端]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=10192</guid>

					<description><![CDATA[<p>
与<a href="https://www.codelast.com/?p=10185" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">Ubuntu系统下的配置</span></a>过程比较相似，先安装Privoxy：</p>
<blockquote>
<p>
		brew install privoxy</p>
</blockquote>
<p>再修改其配置文件&#160;<span style="color:#0000ff;">/usr/local/etc/privoxy/config</span>，在文件末尾添加如下内容：<br />
<span id="more-10192"></span></p>
<pre style="color: rgb(0, 0, 32); background: rgb(246, 248, 255);">
forward-socks5 / <span style="color: rgb(0, 140, 0);">127</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">1</span><span style="color: rgb(48, 128, 128);">:</span><span style="color: rgb(0, 140, 0);">1080</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">.</span> <span style="color: rgb(89, 89, 121);"># SOCKS5代理地址</span>
listen-address <span style="color: rgb(0, 140, 0);">127</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">1</span><span style="color: rgb(48, 128, 128);">:</span><span style="color: rgb(0, 140, 0);">8080</span> <span style="color: rgb(89, 89, 121);"># HTTP代理地址</span>
forward <span style="color: rgb(0, 140, 0);">10</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(48, 128, 128);">*</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(48, 128, 128);">*</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span></pre>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-mac%e7%bb%88%e7%ab%af%e4%bd%bf%e7%94%a8privoxy%e4%bb%a3%e7%90%86/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
与<a href="https://www.codelast.com/?p=10185" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">Ubuntu系统下的配置</span></a>过程比较相似，先安装Privoxy：</p>
<blockquote>
<p>
		brew install privoxy</p>
</blockquote>
<p>再修改其配置文件&nbsp;<span style="color:#0000ff;">/usr/local/etc/privoxy/config</span>，在文件末尾添加如下内容：<br />
<span id="more-10192"></span></p>
<pre style="color: rgb(0, 0, 32); background: rgb(246, 248, 255);">
forward-socks5 / <span style="color: rgb(0, 140, 0);">127</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">1</span><span style="color: rgb(48, 128, 128);">:</span><span style="color: rgb(0, 140, 0);">1080</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">.</span> <span style="color: rgb(89, 89, 121);"># SOCKS5代理地址</span>
listen-address <span style="color: rgb(0, 140, 0);">127</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(0, 140, 0);">1</span><span style="color: rgb(48, 128, 128);">:</span><span style="color: rgb(0, 140, 0);">8080</span> <span style="color: rgb(89, 89, 121);"># HTTP代理地址</span>
forward <span style="color: rgb(0, 140, 0);">10</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(48, 128, 128);">*</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(48, 128, 128);">*</span><span style="color: rgb(32, 0, 128); font-weight: bold;">.</span><span style="color: rgb(48, 128, 128);">*</span><span style="color: rgb(64, 1, 90);">/</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">.</span> <span style="color: rgb(89, 89, 121);"># 内网地址不走代理</span>
forward <span style="color: rgb(32, 0, 128); font-weight: bold;">.</span>abc<span style="color: rgb(32, 0, 128); font-weight: bold;">.</span>com<span style="color: rgb(64, 1, 90);">/</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">.</span> <span style="color: rgb(89, 89, 121);"># 指定域名不走代理</span></pre>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
然后以&nbsp;root 启动Privoxy（如果之前已经启动过，可以先 kill -9&nbsp;杀掉原来的进程再启动）：</p>
<pre style="color: rgb(0, 0, 32); background: rgb(246, 248, 255);">
sudo privoxy <span style="color: rgb(64, 1, 90);">/usr/local/etc/privoxy/config</span></pre>
<p>
<span style="background-color: rgb(255, 255, 255); font-family: Verdana; font-size: 16px; white-space: pre;">再检查一下Privoxy是否启动成功了：</span></p>
<blockquote>
<div>
		<span style="background-color: rgb(255, 255, 255); font-family: Verdana; font-size: 16px; white-space: pre;">codelast@codelast:~$ ps -ef | grep privoxy</span></div>
<div>
		<span style="background-color: rgb(255, 255, 255); font-family: Verdana; font-size: 16px; white-space: pre;">&nbsp; 501&nbsp; 1391&nbsp; &nbsp; &nbsp;1&nbsp; &nbsp;0&nbsp; 1:08PM ??&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0:00.02 privoxy /usr/local/etc/privoxy/config</span></div>
<div>
		<span style="background-color: rgb(255, 255, 255); font-family: Verdana; font-size: 16px; white-space: pre;">&nbsp; 501&nbsp; 1442&nbsp; 1363&nbsp; &nbsp;0&nbsp; 1:23PM ttys003&nbsp; &nbsp; 0:00.00 grep privoxy</span></div>
</blockquote>
<p>然后set两个环境变量：</p>
<pre style="color: rgb(0, 0, 32); background: rgb(246, 248, 255);">
<span style="color: rgb(119, 121, 187); font-weight: bold;">export</span> <span style="color: rgb(0, 125, 69);">http_proxy</span><span style="color: rgb(48, 128, 128);">=</span><span style="color: rgb(16, 96, 182);">&quot;127.0.0.1:8080&quot;</span>
<span style="color: rgb(119, 121, 187); font-weight: bold;">export</span> <span style="color: rgb(0, 125, 69);">https_proxy</span><span style="color: rgb(48, 128, 128);">=</span><span style="color: rgb(16, 96, 182);">&quot;127.0.0.1:8080&quot;</span></pre>
<p><span style="background-color: rgb(255, 255, 255); font-family: Verdana; font-size: 16px; white-space: pre;">现在终端就可以利用由sock5代理转成的http代理，来无障碍地访问各网站了。</span></p>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
	<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-mac%e7%bb%88%e7%ab%af%e4%bd%bf%e7%94%a8privoxy%e4%bb%a3%e7%90%86/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] Ubuntu终端使用Privoxy代理</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-ubuntu%e7%bb%88%e7%ab%af%e4%bd%bf%e7%94%a8privoxy%e4%bb%a3%e7%90%86/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-ubuntu%e7%bb%88%e7%ab%af%e4%bd%bf%e7%94%a8privoxy%e4%bb%a3%e7%90%86/#comments</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Thu, 25 Oct 2018 07:37:18 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[Privoxy]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[代理]]></category>
		<category><![CDATA[终端]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=10185</guid>

					<description><![CDATA[<p>
在Ubuntu下，除了浏览器之外，为了能在系统全局层面上自动使用代理访问那些&#8220;不存在的网站&#8221;，有一个常用的做法就是，在Chrome的SwitchyOmega插件里的&#8220;<span style="color:#0000ff;">自动切换</span>&#8221;情景模式下&#8220;<span style="color:#0000ff;">导出PAC</span>&#8221;，得到一个PAC文件，放在磁盘的某个路径下（假设为：/home/codelast/OmegaProfile__.pac），然后在Ubuntu系统的网络设置里如下设置：<br />
<span id="more-10185"></span><br />
<img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2018/10/ubuntu_network_proxy_use_pac.png" style="width: 850px; height: 387px;" /><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
然后点击&#8220;应用到整个系统&#8221;。<br />
貌似这样做之后，给人的感觉就是，在Ubuntu终端下也可以无障碍地访问Google了，但事实上并不可以&#8212;&#8212;例如，你可以用如下命令试一下：</p>
<blockquote>
<p>
		curl www.google.com</p>
</blockquote>
<p>结果就是并不能打开Google的首页。<br />
这是因为PAC只有在能解析js的客户端（例如Chrome浏览器）上才能生效，Ubuntu终端只认http_proxy和https_proxy两个环境变量。<br />
所以这是不是意味着，我们只要把这两个环境变量设置成SwitchyOmega插件里设置的socks5代理地址就可以了呢？也不行，原因如下：</p>
<blockquote>
<p>
		在Chrome上，是SwitchyOmega插件把HTTP和HTTPS流量转换成了socks协议的流量，才能使用socks代理。而Ubuntu终端是没有这样的协议转换的，所以没法直接使用sock5代理。这时候就需要一个协议转换器，例如Privoxy。</p>
</blockquote>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
所以话不多说，直接安装Privoxy：</p>
<blockquote>
<p>
		sudo apt install privoxy</p>
</blockquote>
<p>然后修改它的配置文件 /etc/privoxy/config，在文件末尾添加如下内容：</p>
<blockquote>
<div>
		forward-socks5 / 127.0.0.1:1080 . # SOCKS5代理地址</div>
<div>
		listen-address 127.0.0.1:8080&#160; &#160; &#160;# HTTP代理地址</div>
<div>
		forward 10.*.*.*/ .&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;# 内网地址不走代理</div>
<div>
		forward .abc.com/</div></blockquote>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-ubuntu%e7%bb%88%e7%ab%af%e4%bd%bf%e7%94%a8privoxy%e4%bb%a3%e7%90%86/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
在Ubuntu下，除了浏览器之外，为了能在系统全局层面上自动使用代理访问那些&ldquo;不存在的网站&rdquo;，有一个常用的做法就是，在Chrome的SwitchyOmega插件里的&ldquo;<span style="color:#0000ff;">自动切换</span>&rdquo;情景模式下&ldquo;<span style="color:#0000ff;">导出PAC</span>&rdquo;，得到一个PAC文件，放在磁盘的某个路径下（假设为：/home/codelast/OmegaProfile__.pac），然后在Ubuntu系统的网络设置里如下设置：<br />
<span id="more-10185"></span><br />
<img decoding="async" alt="" src="https://www.codelast.com/wp-content/uploads/2018/10/ubuntu_network_proxy_use_pac.png" style="width: 850px; height: 387px;" /><br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
然后点击&ldquo;应用到整个系统&rdquo;。<br />
貌似这样做之后，给人的感觉就是，在Ubuntu终端下也可以无障碍地访问Google了，但事实上并不可以&mdash;&mdash;例如，你可以用如下命令试一下：</p>
<blockquote>
<p>
		curl www.google.com</p>
</blockquote>
<p>结果就是并不能打开Google的首页。<br />
这是因为PAC只有在能解析js的客户端（例如Chrome浏览器）上才能生效，Ubuntu终端只认http_proxy和https_proxy两个环境变量。<br />
所以这是不是意味着，我们只要把这两个环境变量设置成SwitchyOmega插件里设置的socks5代理地址就可以了呢？也不行，原因如下：</p>
<blockquote>
<p>
		在Chrome上，是SwitchyOmega插件把HTTP和HTTPS流量转换成了socks协议的流量，才能使用socks代理。而Ubuntu终端是没有这样的协议转换的，所以没法直接使用sock5代理。这时候就需要一个协议转换器，例如Privoxy。</p>
</blockquote>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
所以话不多说，直接安装Privoxy：</p>
<blockquote>
<p>
		sudo apt install privoxy</p>
</blockquote>
<p>然后修改它的配置文件 /etc/privoxy/config，在文件末尾添加如下内容：</p>
<blockquote>
<div>
		forward-socks5 / 127.0.0.1:1080 . # SOCKS5代理地址</div>
<div>
		listen-address 127.0.0.1:8080&nbsp; &nbsp; &nbsp;# HTTP代理地址</div>
<div>
		forward 10.*.*.*/ .&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 内网地址不走代理</div>
<div>
		forward .abc.com/ .&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 指定域名不走代理</div>
</blockquote>
<div>
	<br />
	其中，第1行的&nbsp;127.0.0.1:1080 是你在本地的sock5代理地址，而第二行的&nbsp;127.0.0.1:8080 则是sock5转换成的 http 代理地址，最后两行指定了两个不走代理的地址。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	配置好之后重启Privoxy服务：</div>
<blockquote>
<div>
		sudo /etc/init.d/privoxy restart</div>
</blockquote>
<div>
	然后在命令行设置http_proxy和https_proxy两个环境变量：</div>
<blockquote>
<div>
		export&nbsp;http_proxy=&quot;127.0.0.1:8080&quot;<br />
		export&nbsp;https_proxy=&quot;127.0.0.1:8080&quot;</div>
</blockquote>
<div>
	现在，在终端用 curl www.google.com 测试一下，就会发现可以访问了。如果你想在Ubuntu终端的多个窗口都能生效，可以把这两个export加到 /etc/profile 里。<br />
	大功告成！</p>
<p>	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-ubuntu%e7%bb%88%e7%ab%af%e4%bd%bf%e7%94%a8privoxy%e4%bb%a3%e7%90%86/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
