mirror of
https://github.com/healthchecks/healthchecks.git
synced 2026-04-26 07:25:51 +03:00
[GH-ISSUE #239] CSRF Error with email system #172
Labels
No labels
bug
bug
bug
feature
good-first-issue
new integration
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/healthchecks#172
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @eirannejad on GitHub (Apr 2, 2019).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/239
Hello healthcheck team,
I'm getting a error when clicking on the "Email me a link" button
Healthcheck is running in a docker container and is mapped to port "3003" so url is "localhost:3003"
@cuu508 commented on GitHub (Apr 3, 2019):
Hello @eirannejad, what Dockerfile are you using?
@eirannejad commented on GitHub (Apr 3, 2019):
@cuu508 This one
@eirannejad commented on GitHub (Apr 3, 2019):
And here is my
docker-composefileWe have two domain names. Email is
@mycompany.combut the mailserver and internal servers are under*.mycomp-pdx.come.g.mail.mycomp-pdx.com,data.mycomp-pdx.com,apps.mycomp-pdx.comThis is running in a docker container behind
nginxthat is rerouting traffic to port 3003But even if I open the
localhost:3003in browser on the docker server itself (directly talking to the container), I get the CSRF error.I know I'm doing something wrong but don't know what.
@adampetrovic commented on GitHub (May 23, 2019):
Also seeing this error using the linuxserver docker container. I'm reverse proxying to a subdomain via NGINX.
@cuu508 commented on GitHub (Jun 5, 2019):
I had a look at
galexrt/healthchecks:latest, and I think I understand what's happening, but am not sure what's the best fix.With the above docker-compose.yml file the CSRF validation fails for me too when I access
http://localhost:3003. If I flipHC_DEBUGto True, it gives a slightly more helpful error message:So the Referer header has a "http://" URL but Django expects a "https://" URL.
Django expects a "https://" URL because its
request.is_secure()returnsTrue.request.is_secure()returns True because gunicorn setswsgi.url_schemetohttp.gunicorn does that because, with the default settings, it looks for a X-Forwarded-Ssl header, and find it.
The X-Forwarded-Ssl header is being set in nginx.conf.
In
galexrt/docker-healthchecksREADME they actually have a note about this:So, setting up a HTTPS reverse proxy should fix the problem.
I haven't yet investigated linuxserver's Dockerfile.
@cuu508 commented on GitHub (Jul 20, 2019):
@eirannejad, @adampetrovic did you manage to solve the CSRF verification problem?
@eirannejad commented on GitHub (Jul 20, 2019):
No to be honest. I played with it for a while but couldn't get it to work so I ended up using the cloud
healthchecksfor now. I learned a few things about CSRF during this time so I'll give it another go.@mrceperka commented on GitHub (Oct 23, 2020):
I've manged to hack (DO NOT USE THIS IN PRODUCTION) a way around this error.
I'm using
galexrt/healthchecks:latest.I've had to modify
nginx.confand convert referer's http protocol to https.Working
nginx.conffile (mostly copy of https://github.com/galexrt/docker-healthchecks/blob/master/includes/nginx/nginx.conf)See
# exra line