python相关

python3-ES增加Nginx访问校验出现Authentic

2019-12-13  本文已影响0人  红尘丶

当安全部门检测到系统漏洞后,访问es时,增加了安全校验,无法正常使用。出现如下错误:


elasticsearch.exceptions.AuthenticationException: TransportError
(401, '<html>\r\n<head><title>401 Authorization Required</title></head>\r\n<body bgcolor="white">\r\n<center><h1>401 Authorization Required</h1>/center>\r\n


center>nginx/1.10.3</center>\r\n</body>\r\n</html>\r\n')

通过源码可以我们可以快速的发现并解决问题,可在url中增加相应的用户名、密码。


image.png

解决方案:
1、es = Elasticsearch(hosts='your_host:port', http_auth=('your_user', 'your_pass'))
2、your_host = http://your_user:your_pass@host:port

以上两种方式均有效。

学会阅读源码是很好的进步方式,也是解决问题最快的方法。

上一篇 下一篇

猜你喜欢

热点阅读