VaalaCat / vorker

🔥🔥Vorker is a simple self host cloudflare worker alternative which built with cloudflare's workerd🔥🔥
https://vaala.cat/2023/06/03/Vorker%E5%BC%80%E5%8F%91%E7%AC%94%E8%AE%B0-%E8%87%AA%E5%BB%BA%E7%9A%84%E4%BA%91%E5%87%BD%E6%95%B0%E5%B9%B3%E5%8F%B0/
123 stars 4 forks source link

无法登录 #1

Closed lxxself closed 1 year ago

lxxself commented 1 year ago

使用docker-compose.yml构建 打开控制页面后注册成功,但登录的时候,尽管显示了登录成功,但页面依然有登录按钮,且日志提示如下

06/06/2023 2:46:29 PM
time="2023-06-06T06:46:29Z" level=error msg="Not Authed"
06/06/2023 2:46:29 PM
time="2023-06-06T06:46:29Z" level=error msg="Not Authed"
06/06/2023 2:46:40 PM
time="2023-06-06T06:46:40Z" level=error msg="Not Authed"
VaalaCat commented 1 year ago

可以在浏览器打开f12看看network栏里的login请求返回是什么,重点看看header里的cookie domian和返回是否为OK

lxxself commented 1 year ago

可以在浏览器打开f12看看network栏里的login请求返回是什么,重点看看header里的cookie domian和返回是否为OK

image 请问是哪里出问题了?

VaalaCat commented 1 year ago

观察到你的cookiedomain是localhost,和url不同,应该修改COOKIE_DOMAIN环境变量为192.168.3.100

lxxself commented 1 year ago

还是一样,当前我的配置是这样

version: '3'

services:
  vorker:
    image: vaalacat/vorker
    volumes:
      - ./workerd:/workerd
      - ./workerd-linux-64:/bin/workerd
    environment:
      - DB_PATH=/workerd/db.sqlite
      - WORKERD_DIR=/workerd
      - WORKERD_BIN_PATH=/bin/workerd
      - DB_TYPE=sqlite
      - WORKER_LIMIT=10000
      - WORKER_PORT=8080
      - API_PORT=8888
      - LISTEN_ADDR=0.0.0.0
      - WORKER_DOMAIN_SUFFIX="worker.com" # worker url = SCHEME://WORKERNAME+WORKER_DOMAIN_SUFFIX
      - SCHEME=http
      - ENABLE_REGISTER=false # only allow admin to register
      - COOKIE_NAME=authorization
      - COOKIE_AGE=21600 # sec
      - COOKIE_DOMAIN=192.168.3.100
      - JWT_SECRET=123123
      - JWT_EXPIRETIME=6 # hour
    ports:
      - 8001:8080
      - 8002:8888
    restart: unless-stopped
VaalaCat commented 1 year ago

有可能是docker拉到了老版本的镜像,docker compose pull; docker compose up -d看看,顺便把WORKER_DOMAIN_SUFFIX改成WORKER_URL_SUFFIX

lxxself commented 1 year ago

更新了最新镜像(docker-compose.yml中images尾巴加了latest),修改了WORKER_URL_SUFFIX,情况还是一样。同时使用docker run方式部署,情况也一致。都是注册成功,但无法登陆成功。 先出现这个错误,不清楚是啥

image

然后authorization | Bearer null

image

不知是不是哪里设置不对?

VaalaCat commented 1 year ago

辛苦找一下/login和/register的请求

lxxself commented 1 year ago

这是注册和登陆,是在局域网的ubuntu虚拟机里部署的

image image

然后我尝试了在mac本机部署,倒是一切正常,尽管也是显示authorization:Bearer null

VaalaCat commented 1 year ago

看起来很奇怪,你的浏览器没有保留服务器下发的cookie,也许可以换一个浏览器看一下?另外authrization头为空是符合预期的,cookie和authrization有一个有效就可以通过认证

image
lxxself commented 1 year ago

也是很懵逼,本机环境是 M1 pro,部署环境是 ubuntu 22.04 ,浏览器 firefox、safari、chrome 试了情况一样。看更多人有没有遇到这问题吧。。。 摊手.jpg

VaalaCat commented 1 year ago

稍等我把authrization的header也加上看看能不能暂时解决这个问题

VaalaCat commented 1 year ago

@lxxself 辛苦再docker pull vaalacat/vorker试试,现在把x-authorization-token也加上了

lxxself commented 1 year ago

能登陆了!不过执行 curl 192.168.3.209:8001 -H "Host: worker" 没内容返回正常么,Host不对倒是会返回{"code":1,"error":"not found"}

VaalaCat commented 1 year ago

可以多新建两个worker后curl -vvv 192.168.3.209:8001 -H "Host: worker"试试,然后看一下docker compose logs

lxxself commented 1 year ago

没有出现预期的hello world image

image
lxxself commented 1 year ago

哦,解决了。要chmod +x workerd-linux-64一下

VaalaCat commented 1 year ago

这个问题看起来像是workerd没有启动,我猜测是从网络上下载下来的workerd没有可执行权限,可以试一下

chmod 755 workerd的二进制文件

然后重启一下

docker compose down
docker compose up -d