為什麼透過kcptun+tinyproxy打不開網頁?

為什麼透過kcptun+tinyproxy打不開網頁?

vps上的作業系統:

uname -a
Linux vultr.guest 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64 GNU/Linux

我已經通過這種方式在我的 vps 上建立了tinyproxy 和 kcptun。
小代理

apt-get install tinyproxy
touch  /run/tinyproxy/tinyproxy.pid

保留所有預設設定。

systemctl start tinyproxy
systemctl status  tinyproxy
● tinyproxy.service - Tinyproxy lightweight HTTP Proxy
   Loaded: loaded (/lib/systemd/system/tinyproxy.service; enabled; vendor preset
   Active: active (running) 

tinyproxy狀況良好,可以使用。

kcptun伺服器端
取得 kcptun 伺服器端。

wget https://github.com/xtaci/kcptun/releases/download/v20200226/kcptun-linux-amd64-20200226.tar.gz
tar  -zxf  kcptun-linux-amd64-20200226.tar.gz
cp  server_linux_amd64   /usr/bin/server_linux_amd64

為 kcptun 伺服器建立服務。

vi  /etc/systemd/system/kcptun.service
[Unit]
Description=Kcptun server
Requires=network.target
After=network-online.target

[Service]
Type=simple
User=nobody
RemainAfterExit=yes
ExecStart=/usr/bin/server_linux_amd64 -c /etc/kcptun/conf.json  > /tmp/kcptun.log  2>&1 
ExecReload=/usr/bin/kill -HUP $MAINPID
RestartSec=1min
Restart=on-failure

[Install]
WantedBy=multi-user.target

設定 kcptun 伺服器端的設定檔。

vim  /etc/kcptun/conf.json
{
        "listen": ":20000",
        "target": "127.0.0.1:8888",
        "key": "xxxxxxxx",
        "crypt": "salsa20",
        "mode": "normal",
        "mtu": 1400,
        "sndwnd": 2048,
        "rcvwnd": 2048,
        "datashard": 10,
        "parityshard": 3,
        "dscp": 46,
        "nocomp": true,
        "acknodelay": false,
        "nodelay": 1,
        "interval": 40,
        "resend": 2,
        "nc": 1,
        "sockbuf": 16777217,
        "smuxver": 1,
        "smuxbuf": 16777217,
        "streambuf": 2097152,
        "keepalive": 10,
        "pprof":false,
        "quiet":false,
        "tcp":false
}

8888是tinyproxy的端口,20000是kcptun伺服器和kcptun客戶端之間連接的端口。

開啟連接埠20000

firewall-cmd --zone=public --add-port=20000/udp --permanent
firewall-cmd --reload

Sart kcptun 伺服器。

systemctl start kcptun
systemctl status kcptun
● kcptun.service - Kcptun server
   Loaded: loaded (/etc/systemd/system/kcptun.service; disabled; vendor preset: 
   Active: active (running) since Sun 2020-03-08 08:14:26 UTC; 58min ago
 Main PID: 2082 (server_linux_am)
    Tasks: 6 (limit: 4915)
   CGroup: /system.slice/kcptun.service
           └─2082 /usr/bin/server_linux_amd64 -c /etc/kcptun/conf.json

它的狀態良好。

kcptun 用戶端 在我的本機電腦上,幾乎與在vps上設定kcptun伺服器相同。
獲取 kcptun。

wget https://github.com/xtaci/kcptun/releases/download/v20200226/kcptun-linux-amd64-20200226.tar.gz
tar  -zxf  kcptun-linux-amd64-20200226.tar.gz   

為 kcptun 用戶端建立服務。

vim /etc/systemd/system/kcptun.service
[Unit]
Description=kcptun
Wants=basic.target
After=basic.target network.target

[Service]
User=nobody
Group=nogroup
ProtectSystem=full
ExecStart=/home/debian/client_linux_amd64 -c /home/debian/config.json  > /tmp/kcptun.log 2>&1
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
StandardOutput=syslog
StandardError=syslog
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

設定設定檔。

vim config.json
{
  "localaddr": "127.0.0.1:8123",
  "remoteaddr": "vps_ip:20000",
  "key": "xxxxxxxx",
  "crypt": "salsa20",
  "mode": "normal",
  "dscp": 46,
  "sockbuf": 16777217,
  "smuxver": 2,
  "streambuf": 2097152,
  "nocomp": true
}

在我的瀏覽器上設定代理程式--firefox,127.0.0.1,連接埠8123。

啟動 kcptun 用戶端服務。

systemctl start kcptun
systemctl status kcptun
● kcptun.service - kcptun
   Loaded: loaded (/etc/systemd/system/kcptun.service; disabled; vendor preset: 
   Active: active (running)

它的狀態也很好,我無法透過它打開網頁firefox(8123)--kcptun client(27107)--(27107)kcptun server(8888)--tinyproxy(8888)--target webpage,請檢查連接埠。

lsof -i :20000
COMMAND    PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
server_li 4363 nobody    6u  IPv6  23318      0t0  UDP *:20000 

港口現狀良好。客戶端和伺服器端都沒有日誌檔。

在伺服器端:

cat /tmp/kcptun.log

沒有任何輸出。

在客戶端:

cat /tmp/kcptun.log

沒有任何輸出。

答案1

1.在firefox中設定http和https代理。
2.在vps伺服器端設定config.json。

vim /etc/kcptun/config.json
{
  "listen": ":20000",
  "target": "127.0.0.1:8888",
  "key": "xxxxxxxx",
  "crypt": "salsa20",
  "mode": "normal",
  "dscp": 46,
  "sockbuf": 16777217,
  "smuxver": 2,
  "streambuf": 2097152,
  "nocomp": true
}

相關內容