Django Bad Request (400) Error deploying using Apache / NginX

I am trying to dine my application in VPS mode Debug=False. Debug=Trueworks fine, but when I change it to false, I got this error. I use Apache to render python and Nginx pages to serve my static files. I tried using this [answer]: Debugging Apache / Django / WSGI Bad Request (400) error , but it does not work, at least for me. And this is my wsgi configuration:

#wsgi.py
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
path = '/var/www/example'
if path not in sys.path:
    sys.path.append(path)

And also I added the code below to my settings file:

ALLOWED_HOSTS = [
    '.example.com', # Allow domain and subdomains
    '.example.com.', # Also allow FQDN and subdomains
]
+4
source share
2 answers

, settings.py ALLOWED_HOSTS :

ALLOWED_HOSTS = '*'

- view, :

print(request.META['HTTP_HOST']) # or print(request.get_host())

, , ( ) ALLOWED_HOSTS.

:

  • ALLOWED_HOSTS = '*' , .

  • (apache/nginx).

+18

.

punicode- ALLOWED_HOSTS, .

, Django, ( ), ab (, , ). ( , ab).

punicode

: 20 : 3

punicode

: 20 : 0

0

Source: https://habr.com/ru/post/1527793/


All Articles