Clash_on_linux_server

Tips

Github Acceleration: https://ghproxy.com/

Steps

Download clash core

  1. goto https://github.com/Dreamacro/clash/releases download corresponding releases into your server

    1
    2
    3
    
    # use github acceleration service
    wget https://ghproxy.com/https://github.com/Dreamacro/clash/releases/download/v1.13.0/clash-linux-amd64-v1.13.0.gz
    # or manual download it and use scp/rsync to transfer it to your server
  2. unarchive and install core change <clash> to the actual name of the downloaded file

    1
    2
    3
    4
    
    gzip -d <clash>.gz
    mv <clash>.gz clash.gz
    chmod +x ./clash
    mv ./clash /usr/bin/clash

Make clash configuration directory

1
sudo mkdir /etc/clash

Config.yaml

copy your config.yaml and paste it on your server

1
sudo nvim /etc/clash/config.yaml

Country.mmdb

Go to https://github.com/Dreamacro/maxmind-geoip/releases/

1
sudo wget -O /etc/clash/Country.mmdb https://ghproxy.com/https://github.com/Dreamacro/maxmind-geoip/releases/latest/download/Country.mmdb

Run clash daemon

One Method: manualy run

1
sudo clash -d /etc/clash

Another Method: use service

1
sudo nvim /etc/systemd/system/clash.service

fill it with this content:

1
2
3
4
5
6
7
8
9
[Unit]
Description=clash daemon
[Service]
Type=simple
User=root
ExecStart=/usr/bin/clash -d /etc/clash/
Restart=on-failure
[Install]
WantedBy=multi-user.target

Enable and run clash:

1
sudo systemctl enable --now clash

Show Status

1
sudo systemctl status clash

(optional)Enable Web Control Panel

  1. Add secret: <your password> to /etc/clash/config.yaml
  2. Allow port 9090 on your vps admin panel
  3. restart clash service

    1
    
    sudo systemctl restart clash

Use Proxy

Termainal Environment Variable

use export to enable proxy one session use all_proxy=<cmd> to use inline command proxy. My fish script(~/.config/fish/functions/gfw.fish):

1
2
3
4
5
6
7
8
9
function gfw
    if test "$argv" = "" # if no argument is passed
        echo set global proxy to 127.0.0.1:7890
        export all_proxy=http://127.0.0.1:7890
        return 0
    end

    env all_proxy=http://127.0.0.1:7890 $argv
end

Git

Recommend to use ghproxy instead of proxy.

1
2
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890