我尝试使用Docker配置CockGo,但是,它无法在localhost:8427上可用。问题的原因是什么?当我启动容器并运行curl命令“curl localhost:8427”时,找不到该页面。我将感谢任何建议。
我的docker-compose.yml文件:
centrifugo:
image: centrifugo/centrifugo:v4.0.4
container_name: tradegame_backend_local_centrifugo
command: centrifugo -c /centrifugo/config.json
expose:
- 8427
ports:
- "8427:8427"
volumes:
- "./centrifugo.json:/centrifugo/config.json"
ulimits:
nproc: 65536
nofile:
soft: 65536
hard: 65536
字符串
从容器中取出:
local_centrifugo | {"level":"info","version":"4.0.4","runtime":"go1.19.3","pid":1,"engine":"redis","gomaxprocs":8,"time":"2023-12-18T17:43:30Z","message":"starting Centrifugo"}
local_centrifugo | {"level":"info","path":"/centrifugo/config.json","time":"2023-12-18T17:43:30Z","message":"using config file"}
local_centrifugo | {"level":"info","algorithms":"HS256, HS384, HS512","time":"2023-12-18T17:43:30Z","message":"enabled JWT verifiers"}
local_centrifugo | {"level":"info","time":"2023-12-18T17:43:30Z","message":"Redis: redis:6379/1, using password: false"}
local_centrifugo | {"level":"warn","time":"2023-12-18T17:43:30Z","message":"DEBUG mode enabled, see /debug/pprof"}
local_centrifugo | {"level":"warn","time":"2023-12-18T17:43:30Z","message":"usage of allowed_origins * is discouraged for security reasons, consider setting exact list of origins"}
local_centrifugo | {"level":"info","time":"2023-12-18T17:43:30Z","message":"serving websocket, API, debug endpoints on :8427"}
型
简体中文
{
"v3_use_offset": true,
"token_hmac_secret_key": "XXXXXXXXXXXX",
"admin_password": "XXXXXXXXXXXX",
"admin_secret": "XXXXXXXXXXXX",
"api_key": "XXXXXXXXXXXX",
"port": "8427",
"debug": true,
"allow_subscribe_for_client": true,
"allow_subscribe_for_anonymous": true,
"user_subscribe_to_personal": true,
"user_personal_single_connection": false,
"user_personal_channel_namespace": "personal",
"namespaces": [
{
"name": "personal",
"presence": true
}
],
"engine": "redis",
"redis_address": "redis://redis:6379/1",
"user_status": {
"enabled": true,
"use_redis_from_engine": true
},
"allowed_origins": [
"*"
]
}
型
1条答案
按热度按时间wnrlj8wa1#
原来问题出在URL上。容器可以使用命名空间而不是localhost进行内部通信。我更改了Django配置,它工作了。
字符串