Skip to content

⚠️ This is NOT the official shadowsocks website ⚠️

The official shadowsocks site is at shadowsocks.org

Under the condition of MIT License of the original project, this forked site is used ONLY for non-commercial and personal study purposes. The official shadowsocks site is at shadowsocks.org. In addition, the SEO indexing has been turned off on this site in order to protect the exposure of the official shadowsocks.org on the internet

The official shadowsocks site is at shadowsocks.org

HTTP proxy

Since Shadowsocks does not support it out-of-the-box, this section introduces custom setup for HTTP/HTTPS proxy.

HTTP proxy is very important. Some software can't directly talk to a SOCKS5 proxy because its underlying runtime environment does not have native support for the SOCKS protocol in its core http and https modules. Commonly software with this issue include, but not limited to:

A SOCKS proxy is much lower-level. It doesn't know or care about HTTP. It operates at the Session Layer (Layer 5) and its job is simply to take raw TCP connections and "relay" them. The initial handshake with a SOCKS5 proxy involves a different protocol where the client says, "Please open a TCP connection to this IP address and this port for me." After that, it's just raw data being passed back and forth.

Taking yarn as an example. Node.js's default networking libraries are built to handle the HTTP conversation, they don't know how to perform the initial SOCKS5 handshake.

To use a SOCKS5 proxy, we must use an intermediary tool that creates a local HTTP proxy and forwards its traffic to shadowsocks SOCKS5 proxy. Yarn can then be configured to point to this local HTTP proxy. This process is much like having an interpreter; Yarn speaks HTTP, and HTTP proxy speaks SOCKS5.

HTTP Proxies (Application Layer)

An HTTP proxy understands the HTTP protocol. When we tell a program like Yarn to use one, it still makes a standard HTTP request, but sends it to the proxy first. The request looks something like: GET https://registry.yarnpkg.com/react HTTP/1.1. The proxy reads this, understands it, and then forwards it on behalf of the client. This is a conversation happening at the Application Layer (Layer 7) of the OSI model. Node.js's built-in modules are designed to speak this language.

Installing and Configuring Privoxy

We will use a tool called Privoxy, which is a non-caching web proxy with advanced filtering capabilities. We'll use its "forwarding" feature. It will listen for standard HTTP proxy requests on a local port (e.g., 8118).

Installation

Install Privoxy using system's package manager.

  • macOS (using Homebrew):

    console
    brew install privoxy
  • Debian/Ubuntu:

    console
    sudo apt-get update && sudo apt-get install privoxy
  • Windows (using Chocolatey):

    console
    choco install privoxy

Configuration

Next, we need to edit the Privoxy configuration file to tell it where our SOCKS5 proxy is.

  1. Locate the config file. Common locations are:

    • macOS: /usr/local/etc/privoxy/config or /opt/homebrew/etc/privoxy/config
    • Linux: /etc/privoxy/config
  2. Edit the file with a text editor (e.g., nano, vim, or Emacs).

    WARNING

    The file is very long

  3. Add the forwarding rule. Find the section on forwarding and add the following line. If the line already exists but is commented out, simply uncomment it and edit it. This example assumes our SOCKS5 proxy is running on 127.0.0.1 at port 1080. Change this value to match our SOCKS5 proxy's address and port.

    text
    # format: forward-socks5 / host:port .
    forward-socks5 / 127.0.0.1:1080 .

    INFO

    The . at the end is important; it tells Privoxy to forward all traffic through the SOCKS5 proxy.

Starting Privoxy

After saving the configuration, start the Privoxy service.

  • On macOS (with Homebrew):

    console
    brew services start privoxy
  • On Linux (with systemd):

    console
    sudo systemctl start privoxy
    sudo systemctl enable privoxy

By default, Privoxy will now be running and listening for HTTP proxy requests on 127.0.0.1:8118.

Testing

To make sure everything is working, we can test our HTTP proxy using a command-line tool like curl or a standard web browser. These methods work independently of any software like yarn and will confirm if the proxy server itself is reachable and functioning correctly.

Using curl (Universal Method)

curl is a powerful command-line tool for transferring data with URLs. It's pre-installed on macOS, Linux, and modern versions of Windows. This is the most reliable way to test.

Open up terminal and run the following command. This example assumes our proxy is at http://127.0.0.1:8118.

console
curl --verbose -x http://127.0.0.1:8118 https://ifconfig.me

Command Breakdown:

  • --verbose (-v): This is the most important flag. It shows you the entire connection process, step-by-step.
  • -x: This flag specifies the proxy server's address.
  • https://ifconfig.me: This is a simple website that returns the public IP address it sees.

Test output:

  • ✅ Success: In the verbose output, we will see lines confirming the connection to the proxy first, followed by a connection to the destination. The final output will be the IP address of our proxy server.

    console
    * Trying 127.0.0.1:8118...
    * Connected to 127.0.0.1 (127.0.0.1) port 8118 (#0)
    * Connect-proxy: successfully connected
    > GET https://ifconfig.me/ HTTP/1.1
    ...
    < HTTP/1.1 200 OK
    ...
    
    [IP_ADDRESS_OF_YOUR_PROXY]
  • ❌ Failure: If the proxy is down or configured incorrectly, curl will hang and then time out, or we will see an error like Connection refused or a proxy-specific error message.

Using a Web Browser (Graphical Method)

We can also configure our web browser to use the proxy temporarily:

  1. Open Browser Settings: Go to your browser's Settings.

  2. Find Proxy Settings: Search for "Proxy" in the settings search bar. Click on "Open your computer's proxy settings" or configure it manually in the browser if it allows.

  3. Enter Proxy Address: In the manual proxy configuration section, enter the IP address (e.g., 127.0.0.1) and port (e.g., 8118) of our proxy server.

  4. Test: Save the settings and visit a website that shows your IP address, such as https://www.whatismyip.com/.

    • ✅ Success: The website will display the IP address of our proxy server, not our own home IP.
    • ❌ Failure: The website shows our real IP address, or the browser displays an error page like "The proxy server is refusing connections."

WARNING

Remember to disable the browser proxy setting after you are done testing.

This website is released under the MIT License.