Re: Invalid HTTP_HOST header in shared server
On Jun 27, 2016 6:59 PM, "Luis Zárate"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': /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 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWhoiKyqLc_4F4AdCVa5AUHkeZp1uFYgHHB%3DAPm8ab-iA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Invalid HTTP_HOST header in shared server
nobody knows how to solve this problem? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAG%2B5VyPjP3shHFu5vhmKNzBNneb3xEZUCJ%2BUE6jHsDiTiv1ghQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Invalid HTTP_HOST header in shared server
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': /gunicorn.sock>. So, I think are a nginx bad configuration, but I don't know what is wrong. 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. Thanks -- "La utopía sirve para caminar" Fernando Birri -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAG%2B5VyOwE1%2BpG-zZ6x3769BmTvsRByy6h3bhmCK9uxSTy4y%3DEw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout. #!/bin/bash # ./sites_installer.sh -n -h -u -r -g https://.git -b NAME="" BASE="~" VHOME="/environment/" PHOME="/projects/" PYTHON="/usr/bin/python3" PROJECT_NAME="project" USER=`whoami` SERVER_NAME="project" BRANCH='' REPO="" while getopts ":pfg:b:n:r:h:u:" optname do case "$optname" in "p") PYTHON="/usr/bin/python2" ;; "n") PROJECT_NAME=$OPTARG NAME=$PROJECT_NAME ;; "r") BASE=$OPTARG ;; "h") SERVER_NAME=$OPTARG ;; "u") USER=$OPTARG ;; "g") REPO=$OPTARG ;; "b") BRANCH=$OPTARG ;; "?") echo "-p use python2" echo "-n name of project" echo "-h server name ej. example.com" echo " ? help" return 0 ;; *) # Should not occur echo "Unknown error while processing options" ;; esac done mkdir -p $BASE VHOME=$BASE$VHOME$PROJECT_NAME PHOME=$BASE$PHOME$PROJECT_NAME mkdir -p $PHOME virtualenv -p $PYTHON $VHOME source $VHOME/bin/activate pip install gunicorn cd $PHOME git clone $REPO cd .. mv $NAME $NAME.old mv $NAME.old/$NAME . rm -rf $NAME.old cd $NAME if [ -n $BRANCH ] then git checkout $BRANCH fi pip install -r requirements.txt mkdir -p $PHOME/static/ mkdir -p $PHOME/media/ mkdir -p $PHOME/logs/ mkdir -p $PHOME/certs/ openssl req -subj '/CN='$PROJECT_NAME'/O=SOLVO./C=CR' -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout $PHOME/certs/$NAME.key -out $PHOME/certs/$NAME.crt echo -e `cat << EOF \n[program:$PROJECT_NAME] \ncommand = $PHOME/gunicorn_start ; Command to start app \nuser = $USER ; User to run as \nstdout_logfile = $PHOME/logs/gunicorn_supervisor.log \nredirect_stderr = true ; Save stderr in the same log \nenvironment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8 EOF` > $PHOME/supervisor.txt touch $PHOME/logs/gunicorn_supervisor.log echo -e `cat << EOF #!/bin/bash \n \nNAME="$PROJECT_NAME" # Name of the application \nDJANGODIR=$PHOME # Django project directory \nSOCKFILE=$PHOME/gunicorn.sock # we will communicte using this unix socket \nUSER=$USER # the user to run as \nGROUP=webapps # the group to run as \nNUM_WORKERS=3 # how many worker processes should Gunicorn spawn \nDJANGO_SETTINGS_MODULE=$NAME.settings # which settings file should Django use \nDJANGO_WSGI_MODULE=$NAME.wsgi # WSGI module name \n \necho "Starting \\$NAME as \`whoami\`" \n \n# Activate the virtual environment \ncd \\$DJANGODIR \nsource $VHOME/bin/activate \nexport DJANGO_SETTINGS_MODULE=\\$DJANGO_SETTINGS_MODULE \nexport PYTHONPATH=\\$DJANGODIR:$PYTHONPATH \n \nRUNDIR=$(dirname \\$SOCKFILE) \ntest -d \\$RUNDIR || mkdir -p \\$RUNDIR \n \n# Start your Django Unicorn \n# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon) \nexec $VHOME/bin/gunicorn \\${DJANGO_WSGI_MODULE}:application --name \\$NAME --workers \\$NUM_WORKERS --user=\\$USER --group=\\$GROUP --bind=unix:\\$SOCKFILE --log-level=info --log-file=- EOF` > $PHOME/gunicorn_start chmod u+x $PHOME/gunicorn_start TERMINAR ### echo -e `cat << EOF \nupstream $NAME._app_server { \n# fail_timeout=0 means we always retry an upstream even if it failed \n# to return a good HTTP response (in case the Unicorn master nukes a \n# single worker for timing out). \n \nserver unix:$PHOME/gunicorn.sock fail_timeout=0; \n} \nserver { \n listen :80; \n server_name$SERVER_NAME www.$SERVER_NAME; \n return 301