updated:
To reproduce the issue is very simple with a few steps: 1. Install it on your Ubuntu server by running the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/posthog/HEAD/bin/deploy-hobby)"
During the auto installation process, you will be prompted to enter the domain for your Posthog site, so enter one and wait for the process to finish.
Visit the domain you entered and it is accessbile.
Now reboot your VPS and visit the domain again it is down forever. Not accessbile even if you use your vps ip address.
I've tried this auto-installation and reboot thing three times on the same vps and ended up with the same result. I've also tried it on another vps by a new hosting provider, yet still the same issue. Fresh installation and the site will be down right after your reboot your vps!
The following is the error log I got from the Caddy container, which is generated after the vps reboot:
{"level":"error","ts":1642534398.9394724,"logger":"http.log.error","msg":"dial tcp 172.18.0.4:8000: connect: connection refused","request":{"remote_addr":"67.198.228.123:35424","proto":"HTTP/2.0","method":"GET","host":"<my_posthog_domain>","uri":"/preflight","headers":{"Sec-Ch-Ua":"\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"96\", \"Google Chrome\";v=\"96\"","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36","Sec-Fetch-Site":"cross-site","Accept-Language":"en-US,en;q=0.9","Accept-Encoding":"gzip, deflate, br","Cookie":"phtoolbar=yes; csrftoken=gsVfpdF56rbYgQQdwywH45zi83i386oe5KZZef3mIE00bumaQCG3i4OM35bdJIxQ; ph_sTMFPsFhdP1Ssg_posthog=%7B%22distinct_id%22%3A%22FpLgrw74q9qcclLSJ1bOrzsiPJmZtHdKswxemTFy9LG%22%7D","Cache-Control":"max-age=0","Sec-Ch-Ua-Mobile":"?0","Upgrade-Insecure-Requests":"1","Sec-Fetch-Dest":"document","Sec-Ch-Ua-Platform":"\"macOS\"","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9","Sec-Fetch-Mode":"navigate","Sec-Fetch-User":"?1"},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":"<my_posthog_domain>"}},"duration":0.008754516,"status":502,"err_id":"gicbjv2m4","err_trace":"reverseproxy.statusError (reverseproxy.go:886)"} {"level":"error","ts":1642534401.5881941,"logger":"http.log.error","msg":"dial tcp 172.18.0.4:8000: connect: connection refused","request":{"remote_addr":"67.198.228.123:35424","proto":"HTTP/2.0","method":"GET","host":"<my_posthog_domain>","uri":"/preflight","headers":{"Cache-Control":"max-age=0","Sec-Ch-Ua-Mobile":"?0","Sec-Ch-Ua-Platform":"\"macOS\"","Sec-Fetch-User":"?1","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36","Sec-Ch-Ua":"\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"96\", \"Google Chrome\";v=\"96\"","Sec-Fetch-Mode":"navigate","Accept-Encoding":"gzip, deflate, br","Upgrade-Insecure-Requests":"1","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9","Sec-Fetch-Site":"cross-site","Sec-Fetch-Dest":"document","Accept-Language":"en-US,en;q=0.9","Cookie":"phtoolbar=yes; csrftoken=gsVfpdF56rbYgQQdwywH45zi83i386oe5KZZef3mIE00bumaQCG3i4OM35bdJIxQ; ph_sTMFPsFhdP1Ssg_posthog=%7B%22distinct_id%22%3A%22FpLgrw74q9qcclLSJ1bOrzsiPJmZtHdKswxemTFy9LG%22%7D"},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":"<my_posthog_domain>"}},"duration":0.001907749,"status":502,"err_id":"27e15xwsj","err_trace":"reverseproxy.statusError (reverseproxy.go:886)"}
By the way, this is their documentaion page FYI: https://posthog.com/docs/self-host/deploy/hobby
Original question:
I've installed Posthog with their so-called hobby installation script on my vps and at first it was working fine. But right after I rebooted ubuntu and visited my self-hosted posthog site again, it would not load and just showed a blank page. It seems that something went wrong after I rebooted my vps. I've checked all the services required by Posthog with the command docker ps, and everything is up and running(check the screenshot attached).
I've been trying to figure it out for 4 days yet with no luck. I am new to docker and kubernetes so I do not know what causes the problem and what I should do. Please shed some light on this and help me :(
First things first, this is a docker-compose stack, not Kubernetes.
If you take a look at the script you execute, you can see that it's downlowading docker compose and then uses it to start up your stack.
As such, executing docker-compose stop && docker-compose start
after your rebooted should fix this.
The "problem" here is the docker compose yaml that is used for the hobby project, which includes the following:
caddy:
image: caddy
restart: unless-stopped
ports:
- '80:80'
- '443:443'
The behavior of the unless-stoppped
command is, that a given container is not restarted, if it was stopped.
unless-stopped Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts.
The important part for you is "even after Docker daemon restarts", which is happening as part of your reboot.
Hence, Caddy isn't running, and your service isn't available.