bolucat/naive

Not connecting to NaiveProxy via NaiveProxy Client for macOS and Windows

Closed this issue · 4 comments

I have spun a new server (Ubuntu 20.04) and followed everything on README.md, and systemctl status naiveproxy gives me

ubuntu@ip-172-31-22-1 :~$ systemctl status naiveproxy
● naiveproxy.service - naiveproxy
     Loaded: loaded (/etc/systemd/system/naiveproxy.service; enabled; vendor pr>
     Active: active (running) since Sat 2022-10-08 00:00:00 UTC; 26min ago
   Main PID: 9533 (start.sh)
      Tasks: 19 (limit: 1118)
     Memory: 20.2M
     CGroup: /system.slice/naiveproxy.service
             ├─9533 /bin/bash /etc/naiveproxy/start.sh
             ├─9577 docker compose -f /etc/naiveproxy/docker-naive.yaml up
             └─9587 /usr/libexec/docker/cli-plugins/docker-compose compose -f />

Oct 08 00:00:00 ip-172-31-22-1 systemd[1]: Started naiveproxy.
Oct 08 00:00:00 ip-172-31-22-1 bash[9546]: Warning: No resource found to remo>
Oct 08 00:00:00 ip-172-31-22-1 bash[9567]: No stopped containers
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: Container naiveproxy  Creating
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: Container naiveproxy  Created
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: Attaching to naiveproxy
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: naiveproxy  | {"level":"info","ts">
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: naiveproxy  | {"level":"warn","ts">
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: naiveproxy  | {"level":"info","ts">
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: naiveproxy  | {"level":"info","ts">
lines 1-21/21 (END)

I can also visit the site I put in /var/www/html, with Let's Encrypt certificate fully functioning. But when I tried either running NaiveProxy client on Mac using Proxifier or the one mentioned in README.md on Windows VM, it seemed none of them were establishing a connection to my server.

Any idea what's going on here? Alternatively, is there any complete (and recent) guide on setting up NaiveProxy directly without using Docker? I tried this, and also the official wiki, but this is the first one where I get to open the html file I put into /var/www/html and with SSL fully working.

I have spun a new server (Ubuntu 20.04) and followed everything on README.md, and systemctl status naiveproxy gives me

ubuntu@ip-172-31-22-1 :~$ systemctl status naiveproxy
● naiveproxy.service - naiveproxy
     Loaded: loaded (/etc/systemd/system/naiveproxy.service; enabled; vendor pr>
     Active: active (running) since Sat 2022-10-08 00:00:00 UTC; 26min ago
   Main PID: 9533 (start.sh)
      Tasks: 19 (limit: 1118)
     Memory: 20.2M
     CGroup: /system.slice/naiveproxy.service
             ├─9533 /bin/bash /etc/naiveproxy/start.sh
             ├─9577 docker compose -f /etc/naiveproxy/docker-naive.yaml up
             └─9587 /usr/libexec/docker/cli-plugins/docker-compose compose -f />

Oct 08 00:00:00 ip-172-31-22-1 systemd[1]: Started naiveproxy.
Oct 08 00:00:00 ip-172-31-22-1 bash[9546]: Warning: No resource found to remo>
Oct 08 00:00:00 ip-172-31-22-1 bash[9567]: No stopped containers
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: Container naiveproxy  Creating
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: Container naiveproxy  Created
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: Attaching to naiveproxy
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: naiveproxy  | {"level":"info","ts">
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: naiveproxy  | {"level":"warn","ts">
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: naiveproxy  | {"level":"info","ts">
Oct 08 00:00:00 ip-172-31-22-1 bash[9587]: naiveproxy  | {"level":"info","ts">
lines 1-21/21 (END)

I can also visit the site I put in /var/www/html, with Let's Encrypt certificate fully functioning. But when I tried either running NaiveProxy client on Mac using Proxifier or the one mentioned in README.md on Windows VM, it seemed none of them were establishing a connection to my server.

Any idea what's going on here? Alternatively, is there any complete (and recent) guide on setting up NaiveProxy directly without using Docker? I tried this, and also the official wiki, but this is the first one where I get to open the html file I put into /var/www/html and with SSL fully working.

Mmmm, I can't find any useful information from your logs, you can follow the steps below to debug your caddy:

  • download the caddy :
    mkdir -p /etc/naiveproxy && wget https://github.com/bolucat/peace/releases/download/v2.6.1/caddy-linux-amd64 -O /etc/naiveproxy/caddy
    If you use another architecture, like ARM V8, you can download the prebuild caddy from this release
  • test your config :
    Assume you have written your config under /etc/naiveproxy folder, and named it Caddyfile
cd /etc/naiveproxy && chmod +x caddy
./caddy validate Caddyfile

If the final output line is Valid configuration, it demonstrates that your config is valid, and moving on

  • add systemctl service file
cat > /etc/systemd/system/naiveproxy.service <<EOF
[Unit]
Description=Naiveproxy
Documentation=https://github.com/klzgrad/naiveproxy
After=network.target nss-lookup.target

[Service]
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
ExecStart=/etc/naiveproxy/caddy run -config /etc/naiveproxy/Caddyfile
RestartPreventExitStatus=23

[Install]
WantedBy=multi-user.target
EOF
  • reload systemctl
    systemctl daemon-reload
  • start naiveproxy
systemctl start naiveproxy
systemctl enable naiveproxy

On your MacOS Laptop, you can directly download naiveproxy binary from here : https://github.com/klzgrad/naiveproxy/releases/download/v106.0.5249.91-2/naiveproxy-v106.0.5249.91-2-mac-x64.tar.xz (If you use M series chip, use this one : https://github.com/klzgrad/naiveproxy/releases/download/v106.0.5249.91-2/naiveproxy-v106.0.5249.91-2-mac-arm64.tar.xz)

Decompress it and open your terminal, modify the config.json in your naiveproxy client folder like this :

{
  "listen": "socks://127.0.0.1:1080",
  "proxy": "https://your_user_name:your_password@your_domain_name.com",
  "log": ""
}

Directly start naiveproxy client from your terminal : ./naive config.json
You can use any method to test whether your server works, like open Telegram and point the proxy setting to socks5 and 1080 port, you can see real time logs from your terminal

Hmm, it's weird. I turned it off after submitting this issue yesterday, but now I'm getting

● naiveproxy.service - Naiveproxy
     Loaded: loaded (/etc/systemd/system/naiveproxy.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2022-10-09 00:00:00 UTC; 6s ago
       Docs: https://github.com/klzgrad/naiveproxy
    Process: 468 ExecStart=/etc/naiveproxy/caddy run -config /etc/naiveproxy/Caddyfile (code=exited, status=1/FAILURE)
   Main PID: 1159 (code=exited, status=1/FAILURE)

Oct 09 00:00:00 ip-172-31-22-1 systemd[1]: Started Naiveproxy.
Oct 09 00:00:00 ip-172-31-22-1 caddy[1159]: {"level":"warn","ts":1665293617.0751152,"msg":"unable to determine directory for user configuration; falling back to current directory","error":"neither $XDG_CONFIG_HOME nor $HOME are defined"}
Oct 09 00:00:00 ip-172-31-22-1 caddy[1159]: Error: unknown shorthand flag: 'c' in -config
Oct 09 00:00:00 ip-172-31-22-1 systemd[1]: naiveproxy.service: Main process exited, code=exited, status=1/FAILURE
Oct 09 00:00:00 ip-172-31-22-1 systemd[1]: naiveproxy.service: Failed with result 'exit-code'.

What's going on now? I tried to reboot the instance, but it doesn't work, even though my Caddyfile seems to be a valid configuration:

ubuntu@ip-172-31-22-1:/etc/naiveproxy$ sudo ./caddy validate Caddyfile
2022/10/09 00:00:00.660	INFO	using adjacent Caddyfile
2022/10/09 00:00:00.664	WARN	Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies	{"adapter": "caddyfile", "file": "Caddyfile", "line": 3}
2022/10/09 00:00:00.664	INFO	redirected default logger	{"from": "stderr", "to": "/var/log/caddy/access.log"}
Valid configuration

Emmm, I'm sorry, it's my fault, the systemctl service file should be :

cat > /etc/systemd/system/naiveproxy.service <<EOF
[Unit]
Description=Naiveproxy
Documentation=https://github.com/klzgrad/naiveproxy
After=network.target nss-lookup.target

[Service]
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
ExecStart=/etc/naiveproxy/caddy run --config /etc/naiveproxy/Caddyfile
RestartPreventExitStatus=23

[Install]
WantedBy=multi-user.target
EOF

I miss a - in ExecStart argument, please use command above and try again

If everything's OK, I will close this issue, have a nice day