wo-bisch-server/README.md

110 lines
3.1 KiB
Markdown

# wo-bisch-server - Server fuer den Dienst wo-bisch.ch
Code zum Erstellen des Servers
Spezifikaktion:
- CentOS 8
- Hetzner Cloud Server
- nginx Webserver/Proxy
- wo-bisch-web (Webapplikation/Golang)
- lorahandler (Webapplikation/Golang)
- Redis
## Erstellen des Servers
Mit dem Binary hcloud von:
https://github.com/hetznercloud/cli
Temporaer einen API Key erstellen (nachher wieder loeschen)
`
$ hcloud context create wo-bisch-server
$ hcloud image list # zeigt moegliche Images
$ hcloud server-type list # zeigt moegliche Typen
`
`
$ hcloud server create --name wobisch1 --image centos-8 --type cx11 --ssh-key joerg@cinnamon.nbit.ch
$ hcloud server set-rdns wobisch1 --hostname wobisch1.nbit.ch
$ IPV6="$(hcloud server ip wobisch1 -6)"
$ hcloud server set-rdns wobisch1 --ip $IPV6 --hostname wobisch1.nbit.ch
`
DNS Eintraege erstellen:
`
$ hcloud server ip wobisch1
$ hcloud server ip wobisch1 -6
`
Root-Passwort setzen (das machen wir von Hand)
`
# yum update
`
## Ansible Playbook laufen lassen
`
$ cd ansible
$ ansible-playbook -i production wo-bisch-server.yml --limit wobisch1.wo-bisch.ch # or wobisch2.wo-bisch.ch
`
Mailzugang muss auf mail.nbit.ch noch gegeben werden (main.cf)!
### Let's Encrypt Zertifikat einrichten
`
# curl https://get.acme.sh | sh -s email=info@nbit.ch
# systemctl stop nginx
# acme.sh --issue -d wo-bisch.ch -d www.wo-bisch.ch -w /home/appuser/wo-bisch-web --standalone --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"
# restorecon -irv /etc/letsencrypt
[Sa Feb 27 17:27:34 CET 2021] Your cert is in /root/.acme.sh/wo-bisch.ch/wo-bisch.ch.cer
[Sa Feb 27 17:27:34 CET 2021] Your cert key is in /root/.acme.sh/wo-bisch.ch/wo-bisch.ch.key
[Sa Feb 27 17:27:34 CET 2021] The intermediate CA cert is in /root/.acme.sh/wo-bisch.ch/ca.cer
[Sa Feb 27 17:27:34 CET 2021] And the full chain certs is there: /root/.acme.sh/wo-bisch.ch/fullchain.cer
Install Certificate:
# acme.sh --install-cert -d wo-bisch.ch --key-file /etc/letsencrypt/wo-bisch.ch/wo-bisch.ch.key --fullchain-file /etc/letsencrypt/wo-bisch.ch/fullchain.cer --reloadcmd "service nginx force-reload"
`
### Influxdb Users
Retention: 365 Tage
wobisch1:
admin: admin7355
Org: wobischorg
Bucket: wobischbucket
RW-Token: PWuleFEPB2YSduUkzkcW94V_-KFDK5Fi3MAeaA999Qe51OsGlJJSrcZ41pUAppCwF-z3rUNnyFQQJs8fCSTFzg==
RO-Token: TQvQxxLLAj1kTKWuEqcx7BA-KfE6WtJUeDlPa_Dnvms6Zqf6uh6lMbpXtzcsCjKO_x3PrpxxGDR5E6YnDB5PFg==
wobisch2:
admin: admin7355
Org: wobischorg
Bucket: wobischbucket
RW-Token: Dl1ogBm4U9IgDgMqsHgFX04g4Rn9VyPqc94teQ9QzLztFUSttMTAwkch3TrdUk4c4vtr3eysZbsTaFrTQa-JqA==
RO-Token: hVK-DQk3kQhrTndYCvv8T1c99nSdpUe2wPAzEMH77rpuDKLbEdsI-Ten6S09EPlgKBCPVypYohMNO9AYbt0MlQ==
## Redis Dump
Backup/Restore Tool fuer Redis von https://github.com/yannh/redis-dump-go
`
# cd /var/tmp && wget https://github.com/yannh/redis-dump-go/releases/download/v0.4.1/redis-dump-go-linux-amd64.tar.gz
# tar xzvf redis-dump-go-linux-amd64.tar.gz
# cp redis-dump-go /usr/local/bin
Zum Backup:
$ redis-dump-go -output commands >redis-backup-$(date +%Y%m%W).out
Zum Restore:
$ redis-cli --pipe < redis-backup.out
`