ngx_http_proxy_connect_module
ngx_http_proxy_connect_module copied to clipboard
Basic Auth and Proxy Connect
Hi guys
The NGINX proxy_connect module is not working with basic auth.
Example:
http {
server {
proxy_connect;
proxy_connect_timeout 60s;
location / {
auth_basic "User auth";
auth_basic_user_file /etc/nginx/passwords;
proxy_http_version 1.1;
}
}
}
This command returns my IP address (without AUTH): curl --proxy http://proxy:port https://ifcfg.co/.
This command is blocked as expected: curl --proxy http://127.0.0.1:1441 http://ifcfg.co/.
I am getting: "401 Authorization Required"
The request from ur command curl is http request. This request is not handled by this module. It is handled by original nginx module( http & http auth). Because ur request has no info of authorization, nginx http auth module refused it.
I've the same problem, tried as well
curl --proxy "http://${IP}:${PORT}" --proxy-user 'user:pass' ...
This helped https://github.com/chobits/ngx_http_proxy_connect_module/issues/42#issuecomment-502985437 but I used lua script modification https://github.com/chobits/ngx_http_proxy_connect_module/issues/42#issuecomment-820856840
I've the same problem, Nginx 1.24.0
Problem should position in rewrite_by_lua_file /usr/local/nginx/conf/proxy_auth.lua; because i comment it, the nignx server will work normally.
cat /usr/local/nginx/conf/proxy_auth.lua -- check Proxy-Authorization for https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407 if not ngx.var.http_proxy_authorization then ngx.header["Proxy-Authenticate"] = "Basic realm="Access to internal site"" ngx.exit(407) end
-- transfer Proxy-Authorization header to Authorization for auth basic module ngx.req.set_header("Authorization", ngx.var.http_proxy_authorization)
I've the same problem, Nginx 1.24.0 Problem should position in
rewrite_by_lua_file /usr/local/nginx/conf/proxy_auth.lua;because i comment it, the nignx server will work normally.cat /usr/local/nginx/conf/proxy_auth.lua -- check Proxy-Authorization for https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/407 if not ngx.var.http_proxy_authorization then ngx.header["Proxy-Authenticate"] = "Basic realm="Access to internal site"" ngx.exit(407) end
-- transfer Proxy-Authorization header to Authorization for auth basic module ngx.req.set_header("Authorization", ngx.var.http_proxy_authorization)
Solved,Need nginx_lua_module support, i am newer so stupid