ngx_http_proxy_connect_module icon indicating copy to clipboard operation
ngx_http_proxy_connect_module copied to clipboard

Trying to use with user and password

Open skhaz opened this issue 3 years ago • 1 comments

Is it possible to use with user and password?

Something like that?

curl -vvv "ifconfig.me" -x user:password@localhost:8000

Here my nginx.conf, I tried with auth_basic_user_file , although no luck

worker_processes auto;

daemon off;

events { }

http {
    server_names_hash_bucket_size 128;

    server {
        listen 8000;

        resolver 1.1.1.1;

        proxy_connect;
        proxy_connect_allow all;
        proxy_connect_connect_timeout 10s;
        proxy_connect_read_timeout 10s;
        proxy_connect_send_timeout 10s;

        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;

        location / {
            proxy_pass http://$http_host;
            proxy_set_header Host $http_host;
        }
    }
}
curl -vvv "ifconfig.me" -x user:password@localhost:8000
*   Trying 127.0.0.1:8000...* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
* Proxy auth using Basic with user 'user'
> GET http://ifconfig.me/ HTTP/1.1
> Host: ifconfig.me
> Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==
> User-Agent: curl/7.68.0
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 401 Unauthorized
< Server: nginx/1.21.3
< Date: Sat, 30 Oct 2021 18:07:44 GMT
< Content-Type: text/html
< Content-Length: 179
< Connection: keep-alive
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="Restricted Content"
< 
<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.21.3</center>
</body>
</html>
* Connection #0 to host localhost left intact
*

skhaz avatar Oct 30 '21 18:10 skhaz

#42 answered I guess.

Huelse avatar Feb 17 '22 02:02 Huelse

See this https://github.com/chobits/ngx_http_proxy_connect_module/issues/42#issuecomment-502985437.

chobits avatar Aug 15 '22 03:08 chobits