mirror of
https://github.com/kmvan/x-prober.git
synced 2026-08-13 06:09:30 +08:00
[BUG] Real time update reporting HTTP 401 error #27
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @FrankHCY on GitHub (Oct 10, 2019).
Originally assigned to: @kmvan on GitHub.
Just updated from version 2.1 to 3.3 but got some errors.
My website has a classic HTTP authentication (provided by nginx) and it was working fine in version 2.1
but in version 3.3 after I input the username and password on browser I can see the main page of the prober loaded but there is an alert saying "errors on gathering information, please refresh the page" (I am using simplified chinese so the english version may be different) and real time updating is not working. I checked dev tools of my browser and it says your /?action=fetch encounters a HTTP 401 error (authentication error). It was working fine in version 2.1 so I suppose this is a problem of the new version. Thank you for your work.
@kmvan commented on GitHub (Oct 10, 2019):
猜测因为3.0版本开始使用了restful api,fetch 请求是无状态的,不带
cookies额外header,所以导致了与展示页面的cookie不一致,从而fetch请求不被nginx认可的问题发生。这个问题的解决可以直接在fetch中加上
cookies额外header,但这样会导致不够“纯API”。如果我找不到更好的解决方法,就会在下个版本使用该方法来解决。更好的方法近期我会去研究研究。
@kmvan commented on GitHub (Oct 10, 2019):
能贴一下你的nginx http身份验证配置吗?
@FrankHCY commented on GitHub (Oct 10, 2019):
感谢回复!
nginx site 配置(在
server块里):.htpasswd 文件:
<用户名>:$apr1$<密码阿帕奇散列>就是那种最简单的http验证
@kmvan commented on GitHub (Oct 10, 2019):
有一个思路,就是对url参数进行判断。使用了 ?action= 参数就不进行验证
这样的话,访问探针页面,不带action的,就需要验证,带action参数的就不需要。虽然多了几行判断,但这样至少能保持探针请求的纯净性和安全性。当然具体的判断规则,也可以自行更加深入优化。
@loveyu commented on GitHub (Nov 17, 2019):
遇到了同样的问题。nginx下启动了http身份认证
@kmvan commented on GitHub (Nov 17, 2019):
试试 https://github.com/kmvan/x-prober/issues/45#issuecomment-540542011
@loveyu commented on GitHub (Nov 17, 2019):
我知道这个方案可以解决问题,但问题是我并不想取消这个认证
@kmvan commented on GitHub (Nov 18, 2019):
不是连界面都取消,是取消 fetch 获取信息的部分而已。
@loveyu commented on GitHub (Nov 19, 2019):
理解你说的意思,我只是单纯的不想去改服务器的配置而已,我主要看看基本信息而已。
@FrankHCY commented on GitHub (Nov 19, 2019):
我很理解作者的想法 我也是程序员我也是这样的 程序的风格还是很重要的
我也理解取消fetch的认证可以解决问题 但是我这个服务器里还有其他东西 如果每个链接跟个?fetch就能访问了,我这个认证也就失去意义了
当然我也可以只设置探针url跟?fetch可以访问 但这样子的话还是会把一部分的信息暴露出去 还是违背了我设置认证的初衷 说白了就是 我把全站的authentication全去掉了岂不是用着更方便
而且开这种口子可能会有一些脑子一下想不到的bug 还是少开为好
我现在降级到v2的最新版了 还是非常感谢你的探针 用起来不错
@kmvan commented on GitHub (Nov 19, 2019):
主要是我还没想到如何获取 header request 的值,里面包含的 auth 的信息,只要能获取这个,不管从 PHP 或 JS,就能传递给 fetch 接口。
@kmvan commented on GitHub (Nov 19, 2019):
或者会考虑加一个配置文件php,里面能设置密码或相关的信息(多点服务器等等)
@kmvan commented on GitHub (Nov 19, 2019):
貌似突然想到解决方法了,下个版本见证奇迹
@kmvan commented on GitHub (Nov 20, 2019):
两位试试 3.5 版本?
@loveyu commented on GitHub (Nov 20, 2019):
可以了,不过自动更新失败,只能手动更新
@kmvan commented on GitHub (Nov 20, 2019):
肯定的,从3.5开始才兼容 authorization。
@FrankHCY commented on GitHub (Nov 20, 2019):
非常感谢 但php-latest-version 返回404不知道是哪的问题
@kmvan commented on GitHub (Nov 20, 2019):
正常,因为是最新版php,所以找不到比它更新的版本,就404