services:
centrifugo:
image: centrifugo/centrifugo:v6.0
command: centrifugo --config=config.json
volumes:
- ./config.json:/centrifugo/config.json
ports:
- "8000:8000"
- "8020:10000"
networks:
- web
labels:
- "traefik.enable=true"
- "traefik.docker.network=web"
- "traefik.http.routers.centrifugo.entrypoints=http"
- "traefik.http.routers.centrifugo.rule=(Host(`centrifugo.example.com`))"
- "traefik.http.services.centrifugo.loadbalancer.server.port=8000"
logging:
driver: "json-file"
options:
max-size: "50m"
networks:
web:
external: truedocker compose run centrifugo sh
centrifugo genconfighttps://centrifugal.dev/blog/2022/07/29/101-way-to-subscribe https://centrifugal.dev/docs/server/channels#allow_subscribe_for_client
{
"client": {
"token": {
"hmac_secret_key": "AJenelaixJvvWtH8CNGehRSYpZ0pU8MUZ_E9VuQDUBOOCUhjEzW15C8SZ0EPvL2bhDkYmlqRoeZRcJjn8yE2CA"
},
"allowed_origins": ["*"]
},
"admin": {
"enabled": true,
"password": "LtFt50dgMQaAAwQRo8ypDA",
"secret": "rNmwnukb5svO0rpnqVCBpB1wIf-nS3MY1SrAy_9R9W5vAB8zqHqVQihj1npAb_JsHG-LUDXpyubxXJrcGy0NcA"
},
"http_api": {
"key": "-Yhq41GsH_8bjK9htMT7IpGryxPPHB8yARnvLoiArMFeCyntakVi6DxuWNfwnClf6Jac3nh15BNtr2jMYxrPtg"
},
"channel": {
"namespaces": [
{
"name": "example",
"allow_subscribe_for_client": true,
"history_size": 10,
"history_ttl": "300s"
}
]
},
"grpc_api": {
"enabled": true
}
}https://github.com/centrifugal/centrifuge-js
<script src="https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/[email protected]/dist/centrifuge.js" type="text/javascript"></script>