免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4315 | 回复: 3
打印 上一主题 下一主题

【求助】nginx+uwsgi+django环境搭建--域名问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-06-19 10:57 |只看该作者 |倒序浏览
环境:
nginx-0.8.4
uWSGI-1.2.3
django-1.4.3
python-2.7
搭建nginx+uwsgi+django中发现:我能用ip地址访问,但是域名不行,这是什么原因呢?
域名访问,不行:

IP访问,可以:




nginx配置:


uwsgi配置:
[uwsgi]
socket = :9090
master = true
#chdir = /data/web/django/mysite/mysite
#module = mysite.wsgi
module = django_uwsgi
processes = 8
listen = 120
enable-threads = true
daemonize = /data/web/django/mysite/uwsgi/django_uwsgi.log
pidfile = /data/web/django/mysite/uwsgi/django_uwsgi.pid
pythonpath = /data/web/django/mysite
pythonpath = /data/web/django/mysite/uwsgi
pythonpath = /data/web/django/mysite/mysite
buffer-size =  32768
reload-mercy = 8
vacuum = true

django_uwsgi配置:
import os,sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()


其他配置文件没有任何改变



在通过域名访问时,django_uwsgi日志中出现以下报错:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/base.py", line 179, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/base.py", line 221, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/views/debug.py", line 66, in technical_500_response
    html = reporter.get_traceback_html()
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/views/debug.py", line 287, in get_traceback_html
    return t.render(c)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/base.py", line 140, in render
    return self._render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/base.py", line 823, in render
    bit = self.render_node(node, context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/debug.py", line 74, in render_node
    return node.render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/defaulttags.py", line 281, in render
    return nodelist.render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/base.py", line 823, in render
    bit = self.render_node(node, context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/debug.py", line 74, in render_node
    return node.render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/debug.py", line 84, in render
    output = self.filter_expression.resolve(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/base.py", line 571, in resolve
    obj = self.var.resolve(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/base.py", line 721, in resolve
    value = self._resolve_lookup(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/template/base.py", line 772, in _resolve_lookup
    current = current()
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/http/__init__.py", line 262, in build_absolute_uri
    self.get_host(), self.path)
  File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/http/__init__.py", line 220, in get_host
    raise SuspiciousOperation('Invalid HTTP_HOST header: %s' % host)
django.core.exceptions.SuspiciousOperation: Invalid HTTP_HOST header: www.test_django.com


求大神们帮帮忙,解决一下,感激感激!!

论坛徽章:
16
IT运维版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每月发帖之星
日期:2015-09-11 19:30:52IT运维版块每周发帖之星
日期:2015-09-11 19:20:31IT运维版块每日发帖之星
日期:2015-08-26 06:20:00每日论坛发贴之星
日期:2015-08-20 06:20:00IT运维版块每日发帖之星
日期:2015-08-20 06:20:002015年辞旧岁徽章
日期:2015-03-03 16:54:15金牛座
日期:2014-05-04 16:58:09双子座
日期:2013-12-17 16:44:37辰龙
日期:2013-11-22 15:20:59狮子座
日期:2013-11-18 22:55:08射手座
日期:2013-11-12 10:54:26
2 [报告]
发表于 2013-06-19 12:54 |只看该作者
域名能解析么?

论坛徽章:
0
3 [报告]
发表于 2013-07-16 14:03 |只看该作者
是否在setting中把DEBUG改成了False ,而没有加ALLOWED_HOSTS的允许列表

论坛徽章:
0
4 [报告]
发表于 2013-07-16 21:58 |只看该作者
File "/usr/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/http/__init__.py", line 220, in get_host
    raise SuspiciousOperation('Invalid HTTP_HOST header: %s' % host)
django.core.exceptions.SuspiciousOperation: Invalid HTTP_HOST header: www.test_django.com

估计域名的问题,去掉域名中的下划线试试
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP