noamanahmed / wireguard-http-proxy

An HTTP Proxy which tunnels traffic over wire-guard
33 stars 13 forks source link

curl: (56) Recv failure: Connection reset by peer #6

Open CameronSima opened 5 months ago

CameronSima commented 5 months ago

After setting up and running with docker compose, when issuing this curl: curl -x http://127.0.0.1:8888 http://example.com

I get error: curl: (56) Recv failure: Connection reset by peer.

Startup logs seem good to me:

uard  | **** Activating tunnel /config/wg_confs/wg0.conf ****
wireguard  | Warning: `/config/wg_confs/wg0.conf' is world accessible
wireguard  | [#] ip link add wg0 type wireguard
wireguard  | [#] wg setconf wg0 /dev/fd/63
wireguard  | [#] ip -4 address add 10.68.23.27/32 dev wg0
wireguard  | [#] ip link set mtu 1420 up dev wg0
wireguard  | [#] resolvconf -a wg0 -m 0 -x
wireguard  | [#] wg set wg0 fwmark 51820
wireguard  | [#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
wireguard  | [#] ip -4 rule add not fwmark 51820 table 51820
wireguard  | [#] ip -4 rule add table main suppress_prefixlength 0
wireguard  | [#] iptables-restore -n
wireguard  | **** All tunnels are now active ****
noamanahmed commented 1 month ago

Were you able to resolve this?

Can you SSH into the containers and see if you can access the internet?

VentGrey commented 2 weeks ago

Same thing happening here but the error reads: curl: (28) Failed to connect to 192.168.100.25 port 8888 after 134092 ms: Could not connect to server

widg commented 2 weeks ago
2024-10-26 14:52:54 wireguard  | Port 8888
2024-10-26 14:52:54 wireguard  | Timeout 600
2024-10-26 14:52:54 wireguard  | LogLevel Info
2024-10-26 14:52:54 wireguard  | Syslog On
2024-10-26 14:52:54 wireguard  | DisableViaHeader yes
2024-10-26 14:52:54 wireguard  | #Added by start.sh. These will be overwridden 
2024-10-26 14:52:54 wireguard  | Listen 172.30.0.2
2024-10-26 14:52:54 wireguard  | Allow 172.30.0.2
2024-10-26 14:52:54 wireguard  | Allow 172.30.0.1
2024-10-26 14:52:54 wireguard  | Allow 127.0.0.1
2024-10-26 14:52:54 wireguard  | **** Found WG conf /config/wg_confs/wg0.conf, adding to list ****
2024-10-26 14:52:54 wireguard  | **** Activating tunnel /config/wg_confs/wg0.conf ****
2024-10-26 14:52:54 wireguard  | Warning: `/config/wg_confs/wg0.conf' is world accessible
2024-10-26 14:52:54 wireguard  | [#] ip link add wg0 type wireguard
2024-10-26 14:52:54 wireguard  | [#] wg setconf wg0 /dev/fd/63
2024-10-26 14:52:54 wireguard  | [#] ip -4 address add 10.0.0.2/24 dev wg0
2024-10-26 14:52:54 wireguard  | [#] ip link set mtu 1420 up dev wg0
2024-10-26 14:52:54 wireguard  | [#] resolvconf -a wg0 -m 0 -x
2024-10-26 14:52:54 wireguard  | s6-rc: fatal: unable to take locks: No such file or directory
2024-10-26 14:52:54 wireguard  | [#] wg set wg0 fwmark 51820
2024-10-26 14:52:54 wireguard  | [#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
2024-10-26 14:52:54 wireguard  | [#] ip -4 rule add not fwmark 51820 table 51820
2024-10-26 14:52:54 wireguard  | [#] ip -4 rule add table main suppress_prefixlength 0
2024-10-26 14:52:54 wireguard  | *raw
2024-10-26 14:52:54 wireguard  | -I PREROUTING ! -i wg0 -d 10.0.0.2 -m addrtype ! --src-type LOCAL -j DROP -m comment --comment "wg-quick(8) rule for wg0"
2024-10-26 14:52:54 wireguard  | COMMIT
2024-10-26 14:52:54 wireguard  | *mangle
2024-10-26 14:52:54 wireguard  | -I POSTROUTING -m mark --mark 51820 -p udp -j CONNMARK --save-mark -m comment --comment "wg-quick(8) rule for wg0"
2024-10-26 14:52:54 wireguard  | -I PREROUTING -p udp -j CONNMARK --restore-mark -m comment --comment "wg-quick(8) rule for wg0"
2024-10-26 14:52:54 wireguard  | COMMIT
2024-10-26 14:52:54 wireguard  | **** All tunnels are now active ****

WSL

curl -x http://127.0.0.1:8888 https://chatgpt.com
curl: (56) Received HTTP code 500 from proxy after CONNECT

exec docker

root@wireguard:/# curl https://chatgpt.com
curl: (6) Could not resolve host: chatgpt.com
noamanahmed commented 2 weeks ago

There is a similar issue on this repo where the issue was with IPV6 configuration.

Are you guys using IPV4 or IPV6 in this scenario?

VentGrey commented 1 week ago

Are you guys using IPV4 or IPV6 in this scenario?

I'm using ipv4, however after further experimentation I found that wg-quick uses resolvconf underneath, this could cause DNS issues if the host is using something like systemd-resolved. This happens when using wg-quick using a configuration directly on the hosts machine. I'm not really sure if it makes sense to say this could be causing the same conflict inside the container.