【问题标题】:Not able to open website using domain-name,published using DigitalOcean无法使用域名打开网站,使用 DigitalOcean 发布
【发布时间】:2018-11-25 09:58:18
【问题描述】:

我无法查看我的网站,使用 Django 1.11.13 创建,Python 版本 2.7.12;使用它的域名“www.mysticprogrammer.net”,我在 https://domains.google.I 购买的,使用过 DigitalOcean,作为发布平台。而且,我还添加了 DigitalOcean DNS 服务器,即 ns1、ns2 和 ns3。
该网站打开正常,当我在 url 中输入远程服务器的 IP 地址时。但是当我输入域名时,即'www.mysticprogrammer.com' 我收到如下错误:

  DisallowedHost at /
  Invalid HTTP_HOST header: 'www.mysticprogrammer.net'. You may need to add 
  u'www.mysticprogrammer.net' to ALLOWED_HOSTS.
  Request Method:   GET
  Request URL:  http://www.mysticprogrammer.net/
  Django Version:   1.11.13
  Exception Type:   DisallowedHost
  Exception Value:  
  Invalid HTTP_HOST header: 'www.mysticprogrammer.net'. You may need to add 
  u'www.mysticprogrammer.net' to ALLOWED_HOSTS.
  Exception Location:   /usr/local/lib/python2.7/dist- 
  packages/django/http/request.py in get_host, line 113
  Python Executable:    /usr/bin/python
  Python Version:   2.7.12
  Python Path:  
  ['/home/django/django_project',
   '/home/django/django_project',
   '/usr/bin',
   '/usr/lib/python2.7',
   '/usr/lib/python2.7/plat-x86_64-linux-gnu',
   '/usr/lib/python2.7/lib-tk',
   '/usr/lib/python2.7/lib-old',
   '/usr/lib/python2.7/lib-dynload',
   '/usr/local/lib/python2.7/dist-packages',
   '/usr/lib/python2.7/dist-packages']
   Server time: Fri, 15 Jun 2018 13:56:44 +0000

可以通过转到我在 url http://www.mysticprogrammer.net 中的域名来读取错误。 我已经阅读了所有以前的相关问题,并补充说:

"ALLOWED_HOSTS ['127.0.0.1', '::1', '159.65.158.7', 'fe80::74db:73ff:febe:b3da%eth0','www.mysticprogramer.net','mysticprogrammer. net']" 在 settings.py 和 request.py 中,如错误消息中所述。

但是,似乎没有任何效果。请建议进行适当的更改。远程服务器中所做的更改需要多长时间才能反映在万维网上?!

【问题讨论】:

    标签: python python-2.7 ubuntu-14.04 digital-ocean django-1.11


    【解决方案1】:
    【解决方案2】:

    转到http://www.mysticprogrammer.net 时,500 错误页面清楚地显示ALLOWED_HOSTS 只有['127.0.0.1', '::1', '159.65.158.7', 'fe80::74db:73ff:febe:b3da%eth0'] 而不是域mysticprogrammer.net 本身。

    您不必列出 IP(除非您真的想通过 IP 地址访问网站),但您应该重新启动用于运行 Django 应用程序的任何服务(uwsgi?gunicorn?),以便您对 @ 的更改987654325@上车。

    【讨论】:

      猜你喜欢
      • 2020-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-19
      • 2016-02-29
      • 1970-01-01
      • 2013-09-01
      • 2016-08-24
      相关资源
      最近更新 更多