2014-02-21 91 views
0

當我設置debug = True時,我的項目運行。 當我將調試設置爲False並將ALLOWED_HOSTS設置爲['*']時,它將我重定向到本地IP,我的gunicorn正在運行。django ALLOWED_HOSTS重定向到本地ip

當我設置ALLOWED_HOSTS我的域名,我得到服務器錯誤(500)

有什麼建議?

UPDATE:

我的問題是在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
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. 
+0

謝謝您的回答。更改後,我仍然收到服務器錯誤(500)。 – guyyug

+0

你在調試模式或生產模式下工作嗎? – drabo2005

+0

我的問題是在nginx配置。我更新了我的帖子。謝謝! – guyyug