Invalid HTTP_HOST header in shared server

57 views
Skip to first unread message

Luis Zárate

unread,
Jun 27, 2016, 10:00:02 PM6/27/16
to django...@googlegroups.com
Hi,

I am having some issue with gunicorn/nginx configuration. I have a shared server that support several sites (all based in Django)  with the same ip address.

Invalid HTTP_HOST header: 'www.mysite.com'. You may need to add 'www.mysite.com' to ALLOWED_HOSTS.

I checked and all projects have ALLOWED_HOSTS well configured, so I read with attention the exception and notice that all exception are send by the same gunicon socket
'gunicorn.socket': <socket.socket fd=10, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, laddr=/<path project>/gunicorn.sock>.

So, I think are a nginx bad configuration, but I don't know what is wrong.


I use this attach file as script to create new projects in my server.

Thanks

--
"La utopía sirve para caminar" Fernando Birri


sites_installer.txt

Luis Zárate

unread,
Jul 8, 2016, 11:51:33 AM7/8/16
to django...@googlegroups.com
nobody knows how to solve this problem?

James Schneider

unread,
Jul 9, 2016, 10:55:12 AM7/9/16
to django...@googlegroups.com


On Jun 27, 2016 6:59 PM, "Luis Zárate" <luis...@gmail.com> wrote:
>
> Hi,
>
> I am having some issue with gunicorn/nginx configuration. I have a shared server that support several sites (all based in Django)  with the same ip address.
>
> Invalid HTTP_HOST header: 'www.mysite.com'. You may need to add 'www.mysite.com' to ALLOWED_HOSTS.
>

This would indicate that you are reaching at least one of your Django instances. It's likely that Nginx does not have a matching virtual host (VH) configuration and is using one of your available sites as the fallback default.

> I checked and all projects have ALLOWED_HOSTS well configured, so I read with attention the exception and notice that all exception are send by the same gunicon socket
> 'gunicorn.socket': <socket.socket fd=10, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, laddr=/<path project>/gunicorn.sock>.
>
> So, I think are a nginx bad configuration, but I don't know what is wrong.
>

Have you looked at the logs for Nginx? It should indicate which (VH) is handling each request. If the wrong VH is matching, then it would explain your error message.

If the right VH is matching, then you need to ensure that the VH is pointing at the correct gunicorn instance. The gunicorn logs should also indicate which instance is being called.

>
> I followed this tutorial
> http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
>
> I use this attach file as script to create new projects in my server.
>

The install script doesn't help a while lot, since we'd have to read and replace the variables in our heads. The  relevant portions of the config files would be much more useful.

-James

Reply all
Reply to author
Forward
0 new messages