{"id":1714,"date":"2023-03-26T07:26:23","date_gmt":"2023-03-25T23:26:23","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1714"},"modified":"2023-04-23T21:38:37","modified_gmt":"2023-04-23T13:38:37","slug":"building-http-proxy-service-using-shadowsocks-and-privoxy","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/26\/building-http-proxy-service-using-shadowsocks-and-privoxy\/","title":{"rendered":"Shadowsocks + Privoxy \u642d\u5efa http \u4ee3\u7406\u670d\u52a1"},"content":{"rendered":"<p>\u76ee\u524d\u5f88\u591a\u8f6f\u4ef6\u90fd\u652f\u6301\u914d\u7f6e http \u4ee3\u7406\u6765\u52a0\u901f\u8bbf\u95ee\uff0c\u6216\u8005\u7ed5\u8fc7 GFW \u6765\u83b7\u53d6\u9700\u8981\u7684\u8d44\u6e90\u3002\u6bd4\u5982 docker\u3001git\u3001gcloud\u3001curl \u8fd9\u4e9b\u8f6f\u4ef6\u90fd\u652f\u6301 http \u4ee3\u7406\u3002\u90a3\u4e48\u6211\u4eec\u8be5\u5982\u4f55\u8f7b\u677e\u5730\u57fa\u4e8e shadowsocks \u642d\u5efa\u4e00\u4e2a http \u4ee3\u7406\uff0c\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u4f7f\u7528 privoxy \u4ee3\u7406\u8f6f\u4ef6\u5c06\u6536\u5230\u7684 http \u8bf7\u6c42\u8f6c\u53d1\u7ed9 shadowsocks \u5ba2\u6237\u7aef\u5373\u53ef\u3002<\/p>\n<h2>Shadowsocks \u8f6f\u4ef6\u6574\u4f53\u67b6\u6784<\/h2>\n<p><!-- more --><\/p>\n<p>\u5982\u4e0b\u56fe\u6240\u793a\uff0cshadowsocks \u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff1a\u5ba2\u6237\u7aef\uff08SS Local\uff09\uff0c\u670d\u52a1\u7aef\uff08SS Server\uff09\u3002\u5ba2\u6237\u7aef\u5c31\u662f\u7528\u6765\u505a\u672c\u5730 Sock5 \u4ee3\u7406\u7684\uff0c\u4ee3\u7406\u672c\u5730 PC \u7684\u8bf7\u6c42\u548c\u670d\u52a1\u7aef\u901a\u4fe1\uff0c\u6211\u4eec\u4e00\u822c\u5728\u624b\u673a\u3001\u5e73\u677f\u3001PC \u4e0a\u5b89\u88c5\u7684\u56fe\u5f62\u5316 shadowsokcs \u8f6f\u4ef6\u5c31\u662f SS \u5ba2\u6237\u7aef\u8f6f\u4ef6\uff0c\u5f53\u7136\u5982\u679c\u5728 Linux \u4e0b\uff0c\u4e5f\u6709SS \u5ba2\u6237\u7aef\uff1asslocal\uff0c\u540e\u9762\u4f1a\u4ecb\u7ecd\u5230\u5982\u4f55\u914d\u5408 privoxy \u6765\u5b9e\u73b0 http \u4ee3\u7406\u670d\u52a1\u3002\u670d\u52a1\u7aef\u5c31\u662f\u5728 Linux \u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u7684 shadowsocks \u670d\u52a1\u7aef\u8f6f\u4ef6\uff0c\u4f9b\u5ba2\u6237\u7aef\u8fde\u63a5\uff0c\u6211\u4eec\u4e00\u822c\u8bf4\u7684\u642d\u5efa shadowsocks \u4ee3\u7406\u5c31\u662f\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u5e76\u914d\u7f6e SS Server\u3002 <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u8fd0\u7ef4\/Shadowsocks%20\u8f6f\u4ef6\u6574\u4f53\u67b6\u6784.jpg\" alt=\"Shadowsocks \u8f6f\u4ef6\u6574\u4f53\u67b6\u6784\" \/><\/p>\n<h2>Shadowsocks + privoxy \u642d\u5efa http \u4ee3\u7406\u670d\u52a1\u6b65\u9aa4<\/h2>\n<p>\u6574\u4f53\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u6211\u4eec\u9700\u8981\u627e\u4e00\u53f0\u673a\u5668\u5c06 SS Server \u642d\u5efa\u597d\uff0c\u7136\u540e\u5728\u5c40\u57df\u7f51\u5185\u7684\u4efb\u4f55\u4e00\u53f0 Linux \u670d\u52a1\u5668\u5b89\u88c5 SS Local \u548c Privoxy\uff0cPrivoxy \u66b4\u9732 8118 \u7aef\u53e3\u4f5c\u4e3a http \u4ee3\u7406\u7684\u7aef\u53e3\uff1a <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u8fd0\u7ef4\/Shadowsocks%20+%20privoxy%20\u642d\u5efa%20http%20\u4ee3\u7406\u670d\u52a1\u6b65\u9aa4.jpg\" alt=\"Shadowsocks + privoxy \u642d\u5efa http \u4ee3\u7406\u670d\u52a1\u6b65\u9aa4\" \/><\/p>\n<h3>\u5b89\u88c5\u914d\u7f6e Shadowsocks Server \u7aef\uff08ssserver\uff09<\/h3>\n<p>Shadowsocks \u662f\u7528 Python \u7f16\u5199\u7684\uff0c\u56e0\u6b64\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u76f4\u63a5\u5b89\u88c5\uff08sslocal \u548c ssserver \u5747\u5df2\u5b89\u88c5\uff09\uff1a<\/p>\n<pre><code>sudo pip install shadowsocks<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\u7f16\u5199 Shadowsocks Server \u7aef\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u914d\u7f6e\u76d1\u542c\u7aef\u53e3\uff0c\u52a0\u5bc6\u65b9\u5f0f\uff0c\u5bc6\u7801\u7b49\uff0c\u65b0\u5efa <code>\/etc\/shadowsocks-server.json<\/code> \u6587\u4ef6\uff0c\u586b\u5165\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre><code class=\"language-json\">{\n    &quot;server&quot;: &quot;0.0.0.0&quot;, \n    &quot;server_port&quot;: 1851, # SS Server \u7aef\u53e3\n    &quot;local_address&quot;: &quot;127.0.0.1&quot;, #SS Local \u7aef\u914d\u7f6e\uff0c\u4e0d\u5f71\u54cdServer\u7aef\u4f7f\u7528\n    &quot;local_port&quot;: 1080,  #SS Local \u7aef\u914d\u7f6e\uff0c\u4e0d\u5f71\u54cdServer\u7aef\u4f7f\u7528\n    &quot;password&quot;: &quot;xxxxx&quot;,\n    &quot;timeout&quot;: 300,\n    &quot;method&quot;: &quot;aes-256-cfb&quot;,\n    &quot;fast_open&quot;: false\n}<\/code><\/pre>\n<p>\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u542f\u52a8 SS Server\uff1a<\/p>\n<pre><code>ssserver -c \/etc\/shadowsocks-server.json -d start<\/code><\/pre>\n<h3>\u5b89\u88c5\u914d\u7f6e Shadowsocks \u5ba2\u6237\u7aef\uff08sslocal\uff09<\/h3>\n<p>\u7b2c\u4e00\u6b65\u5df2\u5c06 SS Server \u5b89\u88c5\u5e76\u914d\u7f6e\u5b8c\u6210\uff0c\u670d\u52a1\u7aef\u53e3\u4e3a 1851\uff0c\u63a5\u4e0b\u6765\u5728\u9700\u8981\u5b89\u88c5 http \u4ee3\u7406\u7684\u673a\u5668\u4e0a\u5b89\u88c5\u914d\u7f6e shadowsocks \u5ba2\u6237\u7aef\uff0c\u5b89\u88c5\u65b9\u6cd5\u548c\u7b2c\u4e00\u6b65\u4e00\u6837\uff1a<\/p>\n<pre><code>sudo pip install shadowsocks<\/code><\/pre>\n<p>\u7f16\u5199 SS Local \u5ba2\u6237\u7aef\u914d\u7f6e\u6587\u4ef6\uff0c\u914d\u7f6e\u8fdc\u7a0b\u8fde\u63a5 SS Server \u7684 IP\uff0c\u7aef\u53e3\uff0c\u5bc6\u7801\uff0c\u52a0\u5bc6\u65b9\u5f0f\u7b49\uff0c\u65b0\u5efa <code>\/etc\/shadowsocks-client.json<\/code> \u6587\u4ef6\uff0c\u586b\u5165\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre><code class=\"language-json\">{\n    &quot;server&quot;: &quot;xxx.xxx.xxx.xxx&quot;, # SS Server \u7aef\u670d\u52a1\u5668\u516c\u7f51 IP\n    &quot;server_port&quot;: 1851, # SS Server \u7aef\u53e3\n    &quot;local_address&quot;: &quot;127.0.0.1&quot;, # SS Local \u672c\u5730\u76d1\u542c IP\n    &quot;local_port&quot;: 1080, # SS Local \u672c\u5730\u76d1\u542c\u7aef\u53e3\n    &quot;password&quot;: &quot;xxxxxx&quot;,\n    &quot;timeout&quot;: 300,\n    &quot;method&quot;: &quot;aes-256-cfb&quot;,\n    &quot;fast_open&quot;: false\n}<\/code><\/pre>\n<p>\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u542f\u52a8 SS Local\uff1a<\/p>\n<pre><code>sslocal -c \/etc\/shadowsocks-client.json -d start<\/code><\/pre>\n<p>\u82e5\u62a5<code>ERROR    already started at pid xxx<\/code>\u9519\u8bef\uff0c\u5219\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u542f\u52a8<\/p>\n<pre><code>nohup sslocal -c \/etc\/shadowsocks-client.json start &amp;<\/code><\/pre>\n<h3>\u914d\u7f6e\u793a\u4f8b<\/h3>\n<ul>\n<li><code>\/etc\/shadowsocks-server.json<\/code><\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n  &quot;server&quot;: &quot;0.0.0.0&quot;,\n  &quot;server_port&quot;: 8688,\n  &quot;password&quot;: &quot;123456&quot;,\n  &quot;timeout&quot;: 300,\n  &quot;method&quot;: &quot;rc4-md5&quot;,\n  &quot;fast_open&quot;: false,\n  &quot;workers&quot;: 1\n}<\/code><\/pre>\n<ul>\n<li><code>\/etc\/shadowsocks-client.json<\/code><\/li>\n<\/ul>\n<pre><code class=\"language-json\">{\n    &quot;server&quot;: &quot;127.0.0.1&quot;,\n    &quot;server_port&quot;: 8688,\n    &quot;local_address&quot;: &quot;127.0.0.1&quot;,\n    &quot;local_port&quot;: 1080,\n    &quot;password&quot;: &quot;123456&quot;,\n    &quot;timeout&quot;: 300,\n    &quot;method&quot;: &quot;rc4-md5&quot;,\n    &quot;fast_open&quot;: false\n}<\/code><\/pre>\n<h3>\u5b89\u88c5\u5e76\u914d\u7f6e Privoxy<\/h3>\n<p>Privoxy \u662f\u4e00\u6b3e\u4ee3\u7406\u8f6f\u4ef6\uff0c\u6211\u4eec\u8fd9\u91cc\u7528\u8be5\u4ee3\u7406\u8f6f\u4ef6\u5b9e\u73b0 HTTP \u5230 Socks5 \u7684\u8f6c\u6362\uff0c\u6240\u6709\u6765\u81ea Privoxy \u7684\u8bf7\u6c42\u88ab\u8f6c\u53d1\u5230 SS Local\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u4e00\u4e2a HTTP \u4ee3\u7406\u670d\u52a1\uff0cPrivoxy \u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u76f4\u63a5 yum \u4e00\u952e\u641e\u5b9a\uff1a<\/p>\n<pre><code>sudo yum install privoxy<\/code><\/pre>\n<p>\u7f16\u8f91 Privoxy \u914d\u7f6e\u6587\u4ef6 <code>\/etc\/privoxy\/config<\/code>\uff0c\u641c\u7d22\u5173\u952e\u5b57 <code>listen-address<\/code> \u627e\u5230\u8fd9\u4e00\u53e5\uff0c\u6539\u6210 <code>listen-address 0.0.0.0:8118<\/code>\uff0c\u8868\u793a\u8be5\u4ee3\u7406\u53ef\u4ee5\u5bf9\u5916\u8bbf\u95ee\u3002<br \/>\n\u63a5\u4e0b\u6765\u5728\u8be5\u914d\u7f6e\u8be5\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0 HTTP \u8bf7\u6c42\u8f6c\u53d1\u5230 SS Local Socks5 \u7684\u914d\u7f6e\uff1a<\/p>\n<pre><code>forward-socks5t \/ 127.0.0.1:1080 .<\/code><\/pre>\n<ul>\n<li>forward-socks5t: \u8868\u793a Privoxy \u8f6c\u53d1\u8bf7\u6c42\u5230 Socks5 \u534f\u8bae<\/li>\n<li>127.0.0.1: \u7b2c\u4e8c\u6b65\u4e2d\u542f\u52a8 SS Local \u672c\u5730\u7ed1\u5b9a IP<\/li>\n<li>1080: \u7b2c\u4e8c\u6b65\u4e2d\u542f\u52a8 SS Local \u672c\u5730\u76d1\u542c\u7aef\u53e3<\/li>\n<\/ul>\n<p>\u542f\u52a8 Privoxy\uff1a<\/p>\n<pre><code>systemctl restart privoxy\nsystemctl enable privoxy<\/code><\/pre>\n<h3>\u6d4b\u8bd5\u4ee3\u7406\u662f\u5426\u53ef\u7528<\/h3>\n<pre><code>curl -x privoxy_ip:8118 https:\/\/www.google.com<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u524d\u5f88\u591a\u8f6f\u4ef6\u90fd\u652f\u6301\u914d\u7f6e http \u4ee3\u7406\u6765\u52a0\u901f\u8bbf\u95ee\uff0c\u6216\u8005\u7ed5\u8fc7 GFW \u6765\u83b7\u53d6\u9700\u8981\u7684\u8d44\u6e90\u3002\u6bd4\u5982 docker\u3001gi [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[141,142],"class_list":["post-1714","post","type-post","status-publish","format-standard","hentry","category-devops-base","tag-ssr","tag-142"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1714"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1714\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}