Usage
This page explains how to get started with rehua.
Deployment steps
- Install docker on the server
- Download the
dockerfolder from BozhanL/rehua-doc. You can either rungit clone https://github.com/BozhanL/rehua-doc.gitor click https://github.com/BozhanL/rehua-doc/archive/refs/heads/main.zip to download entire repository, and delete unwanted files - Enter the
dockerfolder bycd docker - Execute
nginx/html/create_web.shto download and compile the web - Replace
logo.jpgandfavicon.jpgwith your own logo innginx/html/rehuafolder - (Optional) Edit the image version for
apiincompose.yamlto match web version. Default ismain - Update
JWT_SECRETincompose.yamlwith your own secret key, generated using OpenSSLopenssl rand -hex 32or other key generator - Edit username, password, connection string for mongo in
mongo/mongo_username.txt,mongo/mongo_password.txt,mongo/mongodb_url.txt. Default isadmin - Execute
certs/create_test_cert.shto create internal certificates - Edit
nginx/conf/conf.d/rehua.confto changeserver_nameto your own domain. - Put SSL/TLS certificate and private key into the local
certs/nginxfolder, and updatessl_certificateandssl_certificate_keyinnginx/conf/conf.d/rehua.conf. (This folder is mounted into the nginx container at/cert.) - Run
docker compose up -dto start all services.
Add First Admin User
- Access MongoDB Shell
Run the following command in your terminal to access the MongoDB shell using
docker-compose:
docker compose exec -it mongo sh -c '
mongosh \
"mongodb://127.0.0.1:27017/?authSource=admin" \
--username "$(cat /run/secrets/mongo_username)" \
--password "$(cat /run/secrets/mongo_password)" \
--tls \
--tlsCAFile /cert/ca.pem \
--tlsCertificateKeyFile /cert/fullchain_with_key.pem \
--tlsAllowInvalidHostnames'
- Insert Admin user document
use rehua
db.users.insertOne({
"userName": "admin1",
"firstName": "Admin",
"lastName": "Admin1",
"password": "$2b$10$hUHQsZLMXpjHMO9qbUhnkuSmo4oKLFrFfog3eTe1.QlPLnQ4ser7a",
"totpSecret": "JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP",
"email": "N/A",
"status": "active",
"homePhoneNumber": "N/A",
"address": "N/A",
"group": "admin",
})
- use a totp website or app to get rolling code for the totp secret
JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP - Login using the username
admin1and the passwordpassword123, then enter the totp rolling code - In the user dashboard reset the
passwordandMFAfor theadmin1user account
Reset Admin password and totp secret
- Access MongoDB Shell
Run the following command in your terminal to access the MongoDB shell using
docker-compose:
docker compose exec -it mongo sh -c '
mongosh \
"mongodb://127.0.0.1:27017/?authSource=admin" \
--username "$(cat /run/secrets/mongo_username)" \
--password "$(cat /run/secrets/mongo_password)" \
--tls \
--tlsCAFile /cert/ca.pem \
--tlsCertificateKeyFile /cert/fullchain_with_key.pem \
--tlsAllowInvalidHostnames'
- Update a users document
use rehua
db.users.updateOne(
{ userName: "REPLACE WITH YOUR USERNAME" },
{
$set: {
password: "$2b$10$hUHQsZLMXpjHMO9qbUhnkuSmo4oKLFrFfog3eTe1.QlPLnQ4ser7a",
totpSecret: "JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP"
}
}
)
- use a totp website or app to get rolling code for the totp secret
JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP - Login using your username and the password
password123, then enter the totp rolling code - In the user dashboard reset the
passwordandMFAfor your user account
Structure diagram
architecture-beta
group servers(server)[Servers]
group main(server)[Main server] in servers
group backup(server)[Backup server] in servers
service db(database)[Database] in main
service disk1(disk)[Storage] in main
service nginx(server)[HTTP gateway] in main
service web(server)[Web services] in main
service api(server)[API services] in main
service disk2(disk)[Backup server] in backup
api:L -- R:nginx
web:T -- B:nginx
db:L -- R:api
web:R -- L:disk1
api:B -- T:disk1
disk1:B --T:disk2
disk1:R --T:db
group staff(server)[Staff]
junction j0 in staff
service computer(server)[Computer] in staff
service tablet(server)[Tablet] in staff
tablet:T -- B:j0
computer:R -- L:j0
service router(internet)[Router]
junction j1
junction j2
j0:R -- L:j1
router:R --L:nginx
j1:T -- B:router