在服务器本地使用admin也登录不了
情况时这样的,登录返回的json为404,然后web界面显示用户名或密码错误: root@VM-8-2-debian:~/14Finger-docker# cat nginx/html/config.json { "BASE_URL_PROD": "http://127.0.0.1:7990", "BASE_URL_DEV": "http://127.0.0.1:8000"
}
root@VM-8-2-debian:~/14Finger-docker# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
201c912fcaf9 nginx:1.20.2 "/docker-entrypoint.…" 31 minutes ago Up 2 minutes 0.0.0.0:7990->80/tcp 14finger-docker_nginx_1
43c18f3d0250 14finger-docker_main "sh -c 'uwsgi --ini …" 31 minutes ago Up 2 minutes 8000/tcp 14finger-docker_main_1
6161e917cdff redis:7.0.4 "docker-entrypoint.s…" 31 minutes ago Up 2 minutes 14finger-docker_redis_1
77e41fa5d790 mysql:8.0.15 "docker-entrypoint.s…" 31 minutes ago Up 2 minutes 3306/tcp, 33060/tcp 14finger-docker_db_1
root@VM-8-2-debian:~/14Finger-docker# curl -X POST http://127.0.0.1:7990/api/user/login
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0'
-H 'Accept: application/json, text/plain, /'
-H 'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2'
-H 'Accept-Encoding: gzip, deflate'
-H 'Content-Type: application/json'
-H 'Origin: http://127.0.0.1:7990'
-H 'Connection: keep-alive'
-H 'Referer: http://127.0.0.1:7990/login'
-d '{"username":"admin","password":"admin","email":null}'
404 Not Found
这是nginx的日志文件: root@201c912fcaf9:/# cat /var/log/nginx/access.log
root@201c912fcaf9:/# cat /var/log/nginx/error.log
root@201c912fcaf9:/# cat /var/log/nginx/access.log
x.x.x.x - - [26/Jan/2024:18:04:03 +0000] "POST /api/user/login HTTP/1.0" 404 153 "http://x.x.x.x:7990/login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0" root@201c912fcaf9:/# cat /var/log/nginx/error.log
2024/01/26 18:04:03 [error] 28#28: *12 connect() failed (111: Connection refused) while connecting to upstream, client: x.x.x.x, server: 127.0.0.1, request: "POST /api/user/login HTTP/1.0", upstream: "http://172.18.0.3:8000/api/user/login", host: "x.x.x.x:7990", referrer: "http://x.x.x.x:7990/login" 2024/01/26 18:04:03 [error] 28#28: *12 open() "/etc/nginx/html/50x.html" failed (2: No such file or directory), client: x.x.x.x, server: 127.0.0.1, request: "POST /api/user/login HTTP/1.0", upstream: "http://172.18.0.3:8000/api/user/login", host: "x.x.x.x:7990", referrer: "http://x.x.x.x:7990/login" root@201c912fcaf9:/#
在我创建了/etc/nginx/html/50x.html后响应,这看起来是服务器内部错误,也就是无法连接http://172.18.0.3:8000/api/user/login导致的:
HTTP/1.1 502 Bad Gateway Server: nginx/1.20.2 Date: Fri, 26 Jan 2024 18:13:21 GMT Content-Type: text/html Content-Length: 4 Connection: keep-alive ETag: "65b3f63e-4"
50x
http://172.18.0.3:8000/api/user/login 172.18.0.3是14finger-docker_main这个容器的IP吗,正好我看到这个容器开放了8000端口
然后这个IP确实是14finger-docker_main这个容器的IP,但是却访问不了8000端口。不知道什么原因
root@VM-8-2-debian:~# telnet 172.18.0.3 8000 Trying 172.18.0.3... telnet: Unable to connect to remote host: Connection refused root@VM-8-2-debian:~# ping 172.18.0.3 PING 172.18.0.3 (172.18.0.3) 56(84) bytes of data. 64 bytes from 172.18.0.3: icmp_seq=1 ttl=64 time=0.050 ms
root@VM-8-2-debian:~# docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 43c18f3d0250 172.18.0.3172.19.0.4
test@43c18f3d0250:/var/www/html/14Finger$ cat /proc/net/tcp sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 0: 0B00007F:AF7F 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 455971 1 00000000feecafcd 100 0 0 10 0 1: 040013AC:D26E 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457088 1 00000000ec3b94a1 20 4 14 10 -1 2: 040013AC:D274 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457090 1 000000000d0ce3c0 20 4 14 10 -1 3: 040013AC:D294 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457098 1 000000006015a24c 20 4 12 10 -1 4: 040013AC:D280 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457092 1 000000003fa5c002 20 4 26 10 -1 5: 040013AC:D25C 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457084 1 00000000ec3f1fe5 20 4 14 10 -1 6: 040013AC:D28C 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457096 1 00000000e1247a65 20 4 30 10 -1 7: 040013AC:D244 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457078 1 0000000002124e88 20 4 31 10 -1 8: 040013AC:D282 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457094 1 00000000d75ee380 20 4 12 10 -1 9: 040013AC:D25E 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457086 1 000000004cf7ef8e 20 4 30 10 -1 10: 040013AC:D24E 020013AC:18EB 01 00000000:00000000 00:00000000 00000000 1000 0 457082 1 000000001c8cbe08 20 4 22 10 -1
这个错误产生的原因是test用户没有写入权限: test@43c18f3d0250:/var/www/html/14Finger$ uwsgi --ini uwsgi.ini [uWSGI] getting INI configuration from uwsgi.ini test@43c18f3d0250:/var/www/html/14Finger$ open("/var/log/djangolog/uwsgi.log"): Permission denied [core/logging.c line 288]
使用root进入容器后给个权限就好: docker exec -u 0 -it 容器ID bash chown -R test:test /var/log/djangolog
或者直接在dockerfile加上这一行 chown -R test:test /var/log/djangolog
POST /api/user/login HTTP/1.0 Host: x.x.x.x:7990 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0 Accept: application/json, text/plain, / Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate Content-Type: application/json Content-Length: 52 Origin: http://x.x.x.x:7990 Connection: keep-alive Referer: http://x.x.x.x:7990/login
{"username":"admin","password":"admin","email":null}
响应: {"message":"璇锋眰鎴愬姛","code":200,"data":"鐧诲綍鎴愬姛"}
妈的,问题就是这样的,很简单,已解决。但是很坑人啊,博主
指纹库是不是有点少,十一条,然后就是如何批量更新指纹库
6