django 1.6
I've got my webserver to redirect www requests to the non-www equivalent. i.e. www.domain.com goes to domain.com
i've got django setup to email me any errors
i'm getting a bunch of errors that look like:
[Django] ERROR: Invalid HTTP_HOST header: 'www.domain.com'.You may need to add u'www.domain.com' to ALLOWED_HOSTS
or
[Django] ERROR: Invalid HTTP_HOST header: '< ip address >'.You may need to add u'< ip address >' to ALLOWED_HOSTS
but the content of the emails is simply:
No stack trace available
Request repr() unavailable.
I know the redirect is working because if i attempt to visit www.domain.com i get redirected to domain.com
I'd like to better inspect the request object to understand how the requests are getting to django. the only requests that should be getting forwarded to django should be the ones going to domain.com.
Does anyone know how i might go about this?
or even better if someone knows what is going on here that would be great.
As requested here is the nginx conf:
server { listen <ip address>:80; server_name ""; return 444; } server{ listen <ip address>:80; server_name www.domain.com; return 301 $scheme://domain.com$request_uri; } #HTTPS server server{ listen <ip address>:80; listen <ip address>:443 ssl; server_name domain.com; location / { uwsgi_pass unix:<path to socket file>; include /etc/nginx/uwsgi_params; } if ($ssl_protocol = ""){ return 301 https://$host$request_uri; } }