preface
The operating system is Ubuntu. The client proxy software is the Python version Shadow Harmony Socks ssLocal.
The SS installation and configuration process is not described here. Default local port 1080, changed to 1081.
Sslocal is a SOcks5 proxy that requires a software to convert SOcks5 to HTTP. Here are polipo and Privoxy.
Polipo seems to be global proxy only, privoxy global/automatic proxy can be implemented.
In the global proxy mode, the proxy is also used to access localhost. As a result, local services may fail to be accessed.
Polipo implements global proxy
Install polipo:
apt-get update
apt-get install polipo
Copy the code
The polipo configuration file /etc/polipo/config contains only logSyslog and logFile. Add the following:
Proxy address for SS
socksParentProxy = "127.0.0.1:1081"
# type
socksProxyType = socks5
Port after HTTP
proxyPort = 8123
# the following is not clear
chunkHighMark = 50331648
objectHighMark = 16384
serverMaxSlots = 64
serverSlots = 16
serverSlots1 = 32
proxyAddress = "0.0.0.0"
Copy the code
8123 is the HTTP proxy port.
Next, add the proxy address to the environment variable. Add the following to /etc/profile:
export http_proxy="http://127.0.0.1:8123"
export https_proxy="http://127.0.0.1:8123"
Copy the code
Reload:
source /etc/profile
Copy the code
Start the polipo:
service polipo start
Copy the code
Test it out:
curl www.google.com
Copy the code
Privoxy implements both global and automatic proxies
Privoxy can be configured with an agent rule file in.action format. Global and automatic proxies are implemented through control rule files.
The action file can be edited manually or generated from gFWList. The privoxy installation and configuration will be introduced, followed by the generation of the Action file.
Install the configuration
Privoxy installation:
apt-get update
apt-get install privoxy
Copy the code
/etc/privoxy
config
Configuration file, this file is very long.*.action
Proxy rule file*.filter
Filter rule filetrust
Why not build ittemplates/
Same as above
The system starts to modify the configuration file.
Privoxy has a filter feature that can be used to block ads. We only want to implement automatic proxy, comment out the filter part in the configuration file:
# About line 435
# filterfile default.filter
# filterfile user.filter # User customizations
Copy the code
We will use a custom action file, so comment out the default action file and add a custom file:
Around line # 386
The default action file
# actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
# actionsfile default.action # Main actions file
# actionsfile user.action # User customizations
Customize the action file
actionsfile my.action
Copy the code
You can specify the translated HTTP proxy address, using the default port 8118:
About line # 7858118 listen - listen - address 127.0.0.1: address [: : 1) : 8118Copy the code
If the proxy rule is written directly to the config file, then the proxy rule and the local SS proxy address are written together:
# / means match all urls, that is, global proxyThe forward - socks5/127.0.0.1:1081.Copy the code
or
Automatic proxy according to rulesThe forward - socks5. Google.com 127.0.0.1:1081.Copy the code
Attention! There’s one more point at the end of each row.
Implementing a global proxy is the first way to write it.
However, if you want to automate the proxy, the second option is not appropriate to write directly in the configuration file. It is more appropriate to write an action file, which is referred to in the configuration file.
Comment it out. Create a new action file named my.action with the following contents:
This line indicates that all entries in this action file use a proxy{+ forward - override {forward - socks5 127.0.0.1:1081.}}# Add a rule
.google.com
Copy the code
To add privoxy’s transformed address http://127.0.0.1:8118 to the environment variable, refer to the Polipo section.
Start Privoxy and Google should be accessible:
service privoxy start
curl www.google.com
Copy the code
Let’s take a look at how to generate an action file using gFWList.
Generate action file
You do not need to restart Privoxy after modifying the config or action files.
The tool used is gfwlist2privoxy. The tool is simple, the documentation is just a few lines long and clearly written.
Installation:
pip install gfwlist2privoxy
Copy the code
Gfwlist2privoxy does not support python3.x, note whether piP2 or PIp3 is used when installing.
Parameter Description:
-i
/--input
Enter, local gFWList file or file URL. I’m going to use the one abovegfwlist-f
/--file
The output, which is the directory of the generated action file. So this is output to/etc/privoxy/gfwlist.action
-p
/--proxy
SS proxy address, which can be modified after generation. Here is the127.0.0.1:1081
-t
/--type
Proxy type, which can also be modified after generation. Here is thesocks5
--user-rule
User-defined rules file, in which rules are appended to the rules generated by gFWList
Example:
gfwlist2privoxy -i https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt -fThe/etc/privoxy gfwlist. Action - p 127.0.0.1:1081 - t socks5Copy the code
Get the file/etc/privoxy gfwlist. Action:
# gfwlist.action generated by gfwlist2privoxy, 2018-08-02 07:36:00 +0000
# https://github.com/snachx/gfwlist2privoxy{+ forward - override {forward - socks5 127.0.0.1:1081.}}# rule list.Copy the code
Actionsfile my.action in /etc/privoxy/config: actionsfile gfwlist.action
other
-
There is also an untried approach to automatic proxying that uses COW.
-
Environment variable configuration many tutorials only add http_proxy, but the actual use of https_proxy also need to be set.
In addition, as for the address writing method, only write 127.0.0.1:8123, encountered some software can not recognize the situation, change to write the full address http://127.0.0.1:8123/ will not have a problem.
Refer to the link
Raspberry PI+SS+Polipo implements universal selective proxy functionality with Privoxy