当我设置debug = True时,我的项目会运行。 当我将debug设置为False并将ALLOWED_HOSTS设置为['*']时,它会将我重定向到我的gunicorn正在运行的本地IP。
当我将ALLOWED_HOSTS设置为我的域时,我收到服务器错误(500)
有什么建议吗?
更新:
我的问题是在nginx配置中,我不得不设置主机。我在配置文件中添加了以下内容,但它确实有效。
proxy_set_header X_FORWARDED_PROTO https; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host mysite.com; proxy_set_header X-Url-Scheme $scheme; proxy_redirect off; proxy_max_temp_file_size 0;
答案 0 :(得分:0)
debug =False that mean your
apps are running in production mode which going to require a localhost
so you will be redirect to that local ip address. now if you
set the ALLOWED_HOSTS to the domain by default you should
change your hostname to that domain name.
so execute this command line first
$ sudo gksu gedit /etc/hostname to edit the hostname file and
add the line www.yourdomain.com
$ sudo /etc/hosts and add the line:
127.0.0.1 www.yourdomain.com localhost
After that set ALLOWED_HOSTS to your domain name and see what you get.