oowl / ngx_stream_socks_module

Socks5 and HTTP proxy server based on nginx stream module implementation.
GNU General Public License v3.0
23 stars 1 forks source link

second user defined by `socks_user_passwd` cannot be used if len(first_user_password) != len(second_user_password) #2

Open muravjov opened 1 year ago

muravjov commented 1 year ago

Having a config like

stream {
    resolver 8.8.8.8 ipv6=off;
    log_format socks 'socks: $socks_connect_addr $socks_name $socks_protocol [$time_local] $remote_addr';

    server {
        listen 0.0.0.0:1080 ssl;
        ...

    socks;
        socks_user_passwd maria aaa;
        socks_user_passwd ilya  bbbb;
        access_log /var/log/nginx/socks_access.log socks;
    }
}

Second user gets an error with this curl command:

$ curl -is --proxy https://ilya:bbbb@localhost:1080 https://ifconfig.me
HTTP/1.1 407 Proxy Authentication Required
Proxy-Authenticate: Basic realm="Test Basic Auth"

On the other hand, if the second password is bbb, not bbbb in the config, everything work fine:

$ curl -is --proxy https://ilya:bbb@localhost:1080 https://ifconfig.me
HTTP/1.0 200 Connection established

HTTP/2 200
access-control-allow-origin: *
content-type: text/plain; charset=utf-8
content-length: 13
date: Tue, 14 Mar 2023 16:44:50 GMT
x-envoy-upstream-service-time: 1
strict-transport-security: max-age=2592000; includeSubDomains
server: istio-envoy
via: 1.1 google
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
...

How to reproduce:

The nginx is built from the ubuntu repo here https://nginx.org/en/linux_packages.html with

# get sources
$ apt-get source nginx

# add github.com/attenuation/ngx_stream_socks_module to configure
$ sed -i 's+--with-stream +--with-stream --add-module=/home/sa/nginx_build/ngx_stream_socks_module +g' debian/rules

# build it
$ debian/rules build

The ngx_stream_socks_module commit is used:

$ git log -1
commit acf31be0a046edf42518958b7a322e5367734761 (HEAD -> main, tag: 0.1.0, tag: 0.1, origin/main, origin/HEAD)
Author: Jun Ouyang <ouyangjun1999@gmail.com>
Date:   Mon Jan 9 22:43:41 2023 +0800

    update readme
oowl commented 1 year ago

@muravjov Thanks for your issues, I will check these issues and try to resolve them later.