healthchecks / healthchecks

Open-source cron job and background task monitoring service, written in Python & Django
https://healthchecks.io
BSD 3-Clause "New" or "Revised" License
8.22k stars 833 forks source link

Bad Request (400) Error Message on Web GUI #842

Closed droidus closed 1 year ago

droidus commented 1 year ago

I am running the docker version. My container OS is Ubuntu 22.04. Docker version 24.0.2, build cb74dfc. Looking through the docker log files, I don't see any glaring error messages.

cuu508 commented 1 year ago

What URL is returning 400?

droidus commented 1 year ago

I am accessing via the internal IP.

cuu508 commented 1 year ago

Is the URL you are accessing "/"?

What is your configuration?

droidus commented 1 year ago

I re-visited my .env file, updated localhost addresses to my actual internal IP assigned to the host, and it is now working.

wabol commented 1 year ago

Excuse me, where can find the. env, I had the same question. thanks!

cuu508 commented 1 year ago

@lyducka you have to create it. See the first step in the "Getting Started" section here: https://github.com/healthchecks/healthchecks/tree/master/docker

wabol commented 1 year ago

@cuu508 Thank you for getting back to me. I appreciate your response.

I attempted to use Docker Hub at 'https://hub.docker.com/r/healthchecks/healthchecks', but I encountered a 400 Bad Request error with the web GUI. I followed the instructions provided in this GitHub repository 'https://github.com/healthchecks/healthchecks/tree/master/docker', but unfortunately, I encountered the same error.

I have already utilized the Docker CLI and docker-compose on Docker Hub. The operating system of my container is CentOS 7, and the Docker version I'm using is 24.0.2.

If you have some time, I would greatly appreciate your assistance with this issue.

Below is the logs

image
cuu508 commented 1 year ago

@lyducka can you please try the following command as-is:

docker run \
  -it \
  --rm \
  --name=healthchecks \
  -p 8000:8000 \
  -e ALLOWED_HOSTS=localhost \
  -e APPRISE_ENABLED=False \
  -e DB=sqlite \
  -e DB_CONN_MAX_AGE=0 \
  -e DB_HOST= \
  -e DB_NAME=/tmp/hc.sqlite \
  -e DB_PASSWORD= \
  -e DB_PORT= \
  -e DB_SSLMODE= \
  -e DB_TARGET_SESSION_ATTRS= \
  -e DB_USER= \
  -e DEBUG=False \
  -e DEFAULT_FROM_EMAIL=healthchecks@example.org \
  -e DISCORD_CLIENT_ID= \
  -e DISCORD_CLIENT_SECRET= \
  -e EMAIL_HOST= \
  -e EMAIL_HOST_PASSWORD= \
  -e EMAIL_HOST_USER= \
  -e EMAIL_PORT=587 \
  -e EMAIL_USE_TLS=True \
  -e EMAIL_USE_VERIFICATION=True \
  -e INTEGRATIONS_ALLOW_PRIVATE_IPS=False \
  -e LINENOTIFY_CLIENT_ID= \
  -e LINENOTIFY_CLIENT_SECRET= \
  -e MASTER_BADGE_LABEL=Mychecks \
  -e MATRIX_ACCESS_TOKEN= \
  -e MATRIX_HOMESERVER= \
  -e MATRIX_USER_ID= \
  -e MATTERMOST_ENABLED=True \
  -e MSTEAMS_ENABLED=True \
  -e OPSGENIE_ENABLED=True \
  -e PAGERTREE_ENABLED=True \
  -e PD_APP_ID= \
  -e PD_ENABLED=True \
  -e PING_BODY_LIMIT=10000 \
  -e PING_EMAIL_DOMAIN=localhost \
  -e PING_ENDPOINT=http://localhost:8000/ping/ \
  -e PROMETHEUS_ENABLED=True \
  -e PUSHBULLET_CLIENT_ID= \
  -e PUSHBULLET_CLIENT_SECRET= \
  -e PUSHOVER_API_TOKEN= \
  -e PUSHOVER_EMERGENCY_EXPIRATION=86400 \
  -e PUSHOVER_EMERGENCY_RETRY_DELAY=300 \
  -e PUSHOVER_SUBSCRIPTION_URL= \
  -e REGISTRATION_OPEN=True \
  -e REMOTE_USER_HEADER= \
  -e RP_ID= \
  -e S3_ACCESS_KEY= \
  -e S3_BUCKET= \
  -e S3_ENDPOINT= \
  -e S3_REGION= \
  -e S3_SECRET_KEY= \
  -e S3_TIMEOUT=60 \
  -e SECRET_KEY=---123 \
  -e SHELL_ENABLED=False \
  -e SIGNAL_CLI_SOCKET= \
  -e SITE_LOGO_URL= \
  -e SITE_NAME=Mychecks \
  -e SITE_ROOT=http://localhost:8000 \
  -e SLACK_CLIENT_ID= \
  -e SLACK_CLIENT_SECRET= \
  -e SLACK_ENABLED=True \
  -e SPIKE_ENABLED=True \
  -e TELEGRAM_BOT_NAME=ExampleBot \
  -e TELEGRAM_TOKEN= \
  -e TRELLO_APP_KEY= \
  -e TWILIO_ACCOUNT= \
  -e TWILIO_AUTH= \
  -e TWILIO_FROM= \
  -e TWILIO_USE_WHATSAPP=False \
  -e USE_PAYMENTS=False \
  -e VICTOROPS_ENABLED=True \
  -e WEBHOOKS_ENABLED=True \
  -e ZULIP_ENABLED=True \
  healthchecks/healthchecks:latest

Does it work? i.e., does the container start, and do you see any errors when opening http://localhost:8000 in the browser?

wabol commented 1 year ago

@lyducka can you please try the following command as-is:

docker run \
  -it \
  --rm \
  --name=healthchecks \
  -p 8000:8000 \
  -e ALLOWED_HOSTS=localhost \
  -e APPRISE_ENABLED=False \
  -e DB=sqlite \
  -e DB_CONN_MAX_AGE=0 \
  -e DB_HOST= \
  -e DB_NAME=/tmp/hc.sqlite \
  -e DB_PASSWORD= \
  -e DB_PORT= \
  -e DB_SSLMODE= \
  -e DB_TARGET_SESSION_ATTRS= \
  -e DB_USER= \
  -e DEBUG=False \
  -e DEFAULT_FROM_EMAIL=healthchecks@example.org \
  -e DISCORD_CLIENT_ID= \
  -e DISCORD_CLIENT_SECRET= \
  -e EMAIL_HOST= \
  -e EMAIL_HOST_PASSWORD= \
  -e EMAIL_HOST_USER= \
  -e EMAIL_PORT=587 \
  -e EMAIL_USE_TLS=True \
  -e EMAIL_USE_VERIFICATION=True \
  -e INTEGRATIONS_ALLOW_PRIVATE_IPS=False \
  -e LINENOTIFY_CLIENT_ID= \
  -e LINENOTIFY_CLIENT_SECRET= \
  -e MASTER_BADGE_LABEL=Mychecks \
  -e MATRIX_ACCESS_TOKEN= \
  -e MATRIX_HOMESERVER= \
  -e MATRIX_USER_ID= \
  -e MATTERMOST_ENABLED=True \
  -e MSTEAMS_ENABLED=True \
  -e OPSGENIE_ENABLED=True \
  -e PAGERTREE_ENABLED=True \
  -e PD_APP_ID= \
  -e PD_ENABLED=True \
  -e PING_BODY_LIMIT=10000 \
  -e PING_EMAIL_DOMAIN=localhost \
  -e PING_ENDPOINT=http://localhost:8000/ping/ \
  -e PROMETHEUS_ENABLED=True \
  -e PUSHBULLET_CLIENT_ID= \
  -e PUSHBULLET_CLIENT_SECRET= \
  -e PUSHOVER_API_TOKEN= \
  -e PUSHOVER_EMERGENCY_EXPIRATION=86400 \
  -e PUSHOVER_EMERGENCY_RETRY_DELAY=300 \
  -e PUSHOVER_SUBSCRIPTION_URL= \
  -e REGISTRATION_OPEN=True \
  -e REMOTE_USER_HEADER= \
  -e RP_ID= \
  -e S3_ACCESS_KEY= \
  -e S3_BUCKET= \
  -e S3_ENDPOINT= \
  -e S3_REGION= \
  -e S3_SECRET_KEY= \
  -e S3_TIMEOUT=60 \
  -e SECRET_KEY=---123 \
  -e SHELL_ENABLED=False \
  -e SIGNAL_CLI_SOCKET= \
  -e SITE_LOGO_URL= \
  -e SITE_NAME=Mychecks \
  -e SITE_ROOT=http://localhost:8000 \
  -e SLACK_CLIENT_ID= \
  -e SLACK_CLIENT_SECRET= \
  -e SLACK_ENABLED=True \
  -e SPIKE_ENABLED=True \
  -e TELEGRAM_BOT_NAME=ExampleBot \
  -e TELEGRAM_TOKEN= \
  -e TRELLO_APP_KEY= \
  -e TWILIO_ACCOUNT= \
  -e TWILIO_AUTH= \
  -e TWILIO_FROM= \
  -e TWILIO_USE_WHATSAPP=False \
  -e USE_PAYMENTS=False \
  -e VICTOROPS_ENABLED=True \
  -e WEBHOOKS_ENABLED=True \
  -e ZULIP_ENABLED=True \
  healthchecks/healthchecks:latest

Does it work? i.e., does the container start, and do you see any errors when opening http://localhost:8000 in the browser?

Hi @cuu508, thanks for your reply. Yes, I use this run a healthchecks service on my Ubuntu, I attempted to access http://192.168.0.28:8000/ on my computer using Chrome, as the Ubuntu server at 192.168.0.28 doesn't have a browser. However, I'm facing an issue where the page isn't loading. I even tried modifying the 'ALLOWED_HOSTS' setting to '0.0.0.0', but unfortunately, the error persists. Below is the screenshot of the error.

image image
cuu508 commented 1 year ago

@lyducka I think you get 400 because 192.168.0.28 is not in ALLOWED_HOSTS. Try this:

docker run \
  -it \
  --rm \
  --name=healthchecks \
  -p 8000:8000 \
  -e ALLOWED_HOSTS=192.168.0.28 \
  -e DEBUG=False \
  -e DB=sqlite \
  -e DB_NAME=/tmp/hc.sqlite \
  -e SITE_ROOT=http://192.168.0.28:8000 \
  healthchecks/healthchecks:latest
wabol commented 1 year ago

@cuu508 Wow, thank you very much! Extremely helpful! it works. I mistakenly thought that ALLOWED_HOSTS was a limitation of the client. Thank you again!

wabol commented 1 year ago

If you use nginx proxy to healthchecks, please set 'ALLOWED_HOSTS=*' 'SITE_ROOT=http://you-domain-name.com' 'PING_ENDPOINT=http://you-domain-name.com/ping/ ' when you use docker run you healthchecks service.

cuu508 commented 1 year ago

PING_ENDPOINT's default value is SITE_ROOT + /ping/, so you should not need to set it explicitly.

Instead of setting ALLOWED_HOSTS=* (which disables Host header validation), you can set it to ALLOWED_HOSTS=you-domain-name.com.

wabol commented 1 year ago

Very helpful, thank you!

PING_ENDPOINT's default value is SITE_ROOT + /ping/, so you should not need to set it explicitly.

Instead of setting ALLOWED_HOSTS=* (which disables Host header validation), you can set it to ALLOWED_HOSTS=you-domain-name.com.