简体   繁体   English

如何使Django站点可通过IP地址访问? (与Helicon Zoo和IIS一起部署)

[英]How to make Django site accessible via IP address ? (deployed with Helicon Zoo and IIS)

I deploy Django with Helicon Zoo and IIS 我用Helicon Zoo和IIS部署Django

I have my Django project runs on localhost:xxxx My IIS goes live, the default site can be accessed by address However my Django project can't be accessed by IP:xxxx. 我的Django项目在localhost:xxxx上运行我的IIS上线了,可以通过地址访问默认站点,但是IP:xxxx无法访问我的Django项目。 It returns : Bad Request - Invalid Hostname HTTP Error 400. The request hostname is invalid. 它返回:错误的请求-无效的主机名HTTP错误400。请求的主机名无效。

How to make my Django site accessible by IP address? 如何通过IP地址访问我的Django网站? Or how to point the IP address directly to my Django project? 或者如何将IP地址直接指向我的Django项目?

For the site to work on all addresses you need to: 为了使网站能够在所有地址上正常工作,您需要:

  1. run IIS manager, 运行IIS管理器,
  2. choose your site with Django project, 选择带有Django项目的网站,
  3. click 'Binding...' in right sidebar, 点击右侧栏中的“绑定...”,
  4. select (or create new) bindingand make sure the IP address field says 'All Unassigned' like on this pic: 选择(或创建新的)绑定,并确保IP地址字段显示为“ All Unassigned”(如以下图片所示):

IIS网站绑定的编辑

It is also necessary to make sure that settings.py for your project has ALLOWED_HOSTS record and it contains the domain name that is used to access your site. 还必须确保您的项目的settings.py具有ALLOWED_HOSTS记录,并且其中包含用于访问您的站点的域名。 Here's the link to the Django docs: https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts 这是Django文档的链接: https : //docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM