我正在使用AWS Ubuntu示例和nginx我试图到达我的应用程序,我得到这个错误:
DisallowedHost at /
Invalid HTTP_HOST header: '34.227.190.72'. You may need to add '34.227.190.72' to ALLOWED_HOSTS.
Request Method: GET
Request URL: http://34.227.190.72/
Django Version: 4.0.4
Exception Type: DisallowedHost
Exception Value:
Invalid HTTP_HOST header: '34.227.190.72'. You may need to add '34.227.190.72' to ALLOWED_HOSTS.
Exception Location: /home/ubuntu/env/lib/python3.8/site-packages/django/http/request.py, line 149, in get_host
Python Executable: /home/ubuntu/env/bin/python3
Python Version: 3.8.10
Python Path:
['/home/ubuntu/authentication',
'/home/ubuntu/env/bin',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/home/ubuntu/env/lib/python3.8/site-packages']
Server time: Tue, 31 May 2022 10:46:53 +0000
我试图在setting.py
文件中添加我的公共地址到ALLOWED_HOSTS
,但它不工作
我的setting.py
文件:
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['34.227.190.72', 'localhost', '127.0.0.1']
1条答案
按热度按时间pxiryf3j1#
在修改www.example.com后重新启动EC2示例settings.py在我的情况下工作。我还发现,如果你正在使用supervisor,只要在settings.py文件中进行修改,简单地重新启动supervisor也可以工作。