✏️ ️1

PAC(Proxy auto-config) means Proxy automatic configuration service, mainly through Javascript files to resolve your domain name information to carry out KX(scientific) Internet access, features:

  • Matches the response speed block
  • You can customize the proxy domain name
  • You can customize the domain name without proxy
  • Access denied services can bypass agents, reduce resource consumption, and speed response
  • You can also configure the proxy based on available data such as the IP address/date and time of the host/user of the requested web site
function FindProxyForURL(url, host) {
    url = url.toLowerCase();
    host = host.toLowerCase();

    if (
        shExpMatch(url, "*youtube*") ||
        shExpMatch(url, "*google*")) {
        return "PROXY proxy_server";
    }
    return "DIRECT";
}
Copy the code

The following rules are defined in the PAC file above:

  • The requested address containsyoutubeorgoogleThe data will be used by proxy
  • The rest don’t use proxies

Note:

  • HTTPS requests do not use proxy forwarding by default
  • HTTP requests use proxy forwarding by default
  • You will need toproxy_serverReplace it with your proxy server address string, as in"127.0.0.1:9000"
  • Save the files you can usefile:///Is configured as the proxy PAC path
  • You can also use the server file return method

✏️ 2. F l a s k

#! /usr/bin/env python
# _*_ Coding: UTF-8 _*_

from flask import Flask, send_file

app = Flask(__name__, template_folder='/', static_folder="", static_url_path="")


@app.route('/')
def index() :
    return send_file(r'./pac.js')


if __name__ == '__main__':
    host = '0.0.0.0'
    port = 2345
    debug = False
    app.run(debug=debug, host=host, port=port)
Copy the code

Of course, you may need to save a pac.js pac file in the same directory, and when you start you can configure the PAC proxy using the service address.

✏️ 3. w i n d o w s

We can use the PAC proxy service under Windows:

  • usewinSummon the start menu
  • The inputThe agent
  • chooseProxy Server Settings
  • inAutomatic setting agentIn the options barUsing a scriptOpen and enter the PAC service address inScript address

Now that the configuration is complete, you can go online using PAC KX(Science).