SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
20.44k stars 2.44k forks source link

HTTP Inbound: authorization not working #294

Closed mazzz1y closed 1 year ago

mazzz1y commented 1 year ago

Welcome

Description of the problem

When inbound.http.users[] enabled all requests rejecting with 407 error.

HTTP and Mixed inbounds

~ curl -x 'http://test:xxxx@sing-box:1080' -i ifconfig.co
HTTP/1.1 407 Proxy Authentication Required
Content-Length: 0

The same request works with other http proxies(*ray for example)

Version of sing-box

```console $ sing-box version 1.1.1 Environment: go1.19.4 linux/amd64 Tags: with_v2ray_api,with_utls Revision: 2016217c86e85391b5a337e338dc79ef783ca29e CGO: disabled ```

Server and client configuration file

```console { "log": { "disabled": false, "level": "debug" }, "dns": { "final": "local", "strategy": "ipv4_only", "servers": [ { "tag": "local", "address": "1.1.1.1", "detour": "direct-out" } ] }, "route": { "geoip": { "path": "/data/geoip.db", "download_detour": "direct-out" }, "geosite": { "path": "/data/geosite.db", "download_detour": "direct-out" }, "final": "block-out", "rules": [ { "inbound": "mixed-in", "auth_user": "test", "outbound": "direct-out" } ] }, "inbounds": [ { "type": "direct", "tag": "dns-in", "listen": "::", "listen_port": 5053 }, { "type": "mixed", "tag": "mixed-in", "listen": "::", "listen_port": 1080, "sniff": true, "domain_strategy": "prefer_ipv4", "users": [ { "username": "test", "password": "xxxx" } ] } ], "outbounds": [ { "type": "block", "tag": "block-out" }, { "type": "direct", "tag": "direct-out" } ] } ```

Server and client log file

```console ~ curl -x 'http://test:xxxx@sing-box:1080' -i ifconfig.co HTTP/1.1 407 Proxy Authentication Required Content-Length: 0 ``` ```console sing-box | INFO[0000] inbound/direct[dns-in]: tcp server started at [::]:5053 sing-box | INFO[0000] inbound/direct[dns-in]: udp server started at [::]:5053 sing-box | INFO[0000] inbound/mixed[mixed-in]: tcp server started at [::]:1080 sing-box | INFO[0000] sing-box started (0.00s) sing-box | INFO[0001] [3397797835] inbound/mixed[mixed-in]: inbound connection from 172.20.0.11:52930 sing-box | INFO[0001] [3397797835] inbound/mixed[mixed-in]: inbound connection to ifconfig.co:80 sing-box | DEBUG[0001] [3397797835] router: sniffed protocol: http, domain: ifconfig.co sing-box | DEBUG[0001] [3397797835] dns: lookup domain ifconfig.co sing-box | INFO[0001] outbound/direct[direct-out]: outbound packet connection to 1.1.1.1:53 sing-box | INFO[0001] [3397797835] dns: lookup succeed for ifconfig.co: 172.64.111.32 172.64.110.32 2606:4700:e0::ac40:6f20 2606:4700:e0::ac40:6e20 sing-box | DEBUG[0001] [3397797835] dns: resolved [172.64.111.32 172.64.110.32 2606:4700:e0::ac40:6f20 2606:4700:e0::ac40:6e20] sing-box | INFO[0001] [3397797835] outbound/block[block-out]: blocked connection to ifconfig.co:80 sing-box | DEBUG[0001] [3397797835] inbound/mixed[mixed-in]: connection closed: process connection from 172.20.0.11:52930: Get "http://ifconfig.co/": EOF | write tcp 172.20.0.17:1080->172.20.0.11:52930: write: broken pipe ```
mazzz1y commented 1 year ago

https://github.com/SagerNet/sing/pull/12

Oh, I see that @isnowly already fixed it. It works