我已经在 Azure 上的 CentOS 7 机器上安装了 nginx,并且对其进行了如下配置:
server {
listen 80;
server_name mywhateverdomain.com;
return 301 www.mywhateverdomain.com.br$request_uri;
}
server {
listen 80;
server_name www.mywhateverdomain.com.br;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/;
}
}
但每当我尝试http://mywhateverdomain.com
从网络浏览器访问时,都会收到以下消息:
DisallowedHost at /
Invalid HTTP_HOST header: 'mywhateverdomain.com.br'. You may need to add u'mywhateverdomain.com.br' to ALLOWED_HOSTS.
经过搜索,我发现了很多有关 Django 和更新文件的资源ALLOWED_HOSTS
,settings.py
但问题是我不使用 Django,而且我的 Linux 发行版中也没有settings.py
(到目前为止)。
http://www.mywhateverdomain.com
从网络浏览器访问就可以了。
这是浏览器中公开的回溯:
Environment:
Request Method: GET
Request URL: http://mywhateverdomain.com.br/
Django Version: 1.10.6
Python Version: 2.7.12
Installed Applications:
('django_cleanup',
'website.apps.VideoConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
42. response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _legacy_get_response
244. response = middleware_method(request)
File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py" in process_request
57. host = request.get_host()
File "/usr/local/lib/python2.7/dist-packages/django/http/request.py" in get_host
113. raise DisallowedHost(msg)
Exception Type: DisallowedHost at /
Exception Value: Invalid HTTP_HOST header: 'mywhateverdomain.com.br'. You may need to add u'mywhateverdomain.com.br' to ALLOWED_HOSTS.
/usr/local/lib/python2.7/
顺便说一句,我的 CentOS 中没有目录,也没有common.py
、request.py
等文件。这可能是什么问题?