Change Default Password for Redis
-
The following is an example with the new password
f8K5ZT3aQXTb
for redis. -
Be sure to change the password for redis in the actual configuration
-
Advance data backup is recommended before operation.
-
Microservices version: v3.7.0+.
- microservice version>=5.1.0
- microservice version<5.1.0
Enter the hap-sc container and log in to Redis
docker exec -it $(docker ps | grep hap-sc | awk '{print $1}') bash -c 'redis-cli -a 123456'
Enter the hap-community container and log in to Redis
docker exec -it $(docker ps | grep hap-community | awk '{print $1}') bash -c 'redis-cli -a 123456'
-
Change Redis password
config set requirepass f8K5ZT3aQXTb
-
Modify the file docker-compose.yaml to add environment variables and port mapping.
The default path for file docker-compose.yaml: /data/hap/script/docker-compose.yaml
- microservice version>=5.1.0
- microservice version<5.1.0
Add a new environment variable ENV_REDIS_PASSWORD
to specify the new password for redis under the app service.
ENV_REDIS_PASSWORD: "f8K5ZT3aQXTb"
Add port mapping under the sc service to map port 6379 out of the container (you can leave port mapping off if don't need external access).
- 6379:6379
Configuration example of file docker-compose.yaml
version: '3'
services:
app:
image: nocoly/hap-community:5.7.1
environment:
ENV_ADDRESS_MAIN: "https://hap.domain.com"
ENV_APP_VERSION: "5.7.1"
ENV_API_TOKEN: "****"
ENV_REDIS_PASSWORD: "f8K5ZT3aQXTb" # Add a new variable and change it to the actual password
ports:
- 8880:8880
volumes:
- ../data:/data/hap/data
sc:
image: nocoly/hap-sc:3.0.0
environment:
<<: *app-environment
ports:
- 3306:3306 # Add Redis port mapping. If external access to Redis is not required, there is no need to add this port mapping
volumes:
- ./volume/data/:/data/
- ../data:/data/hap/data
Add a new environment variable ENV_REDIS_PASSWORD
to specify the new password for redis under the app service.
ENV_REDIS_PASSWORD: "f8K5ZT3aQXTb"
Add port mapping under the app service to map port 6379 out of the container (you can leave port mapping off if don't need external access).
- 6379:6379
Configuration example of file docker-compose.yaml
version: '3'
services:
app:
image: nocoly/hap-community:5.7.1
environment:
ENV_ADDRESS_MAIN: "https://hap.domain.com"
ENV_APP_VERSION: "5.7.1"
ENV_API_TOKEN: "****"
ENV_REDIS_PASSWORD: "f8K5ZT3aQXTb" # Add a new variable and change it to the actual password
ports:
- 8880:8880
- 6379:6379 # Add Redis port mapping. If external access to Redis is not required, there is no need to add this port mapping
volumes:
- ./volume/data/:/data/
- ../data:/data/hap/data
-
Restart the microservice in the directory of Install Manager to take effect.
bash service.sh restartall