简体   繁体   中英

django cms - The requested URL /en/ was not found on this server - postgresql, nginx, gunicorn

Program versions:

django cms 3.0
python 3.4.2
django 1.7.3

Settings:

DEBUG = False
ALLOWED_HOSTS = ['localhost','localhost:8000',]

When using Sqlite, everything works fine.
With PostgreSQL, I get: The requested URL /en/ was not found on this server.
(With DEBUG - True, with either database, works fine.)

What am I doing wrong?

I forgot to mention that:

  • I run django-cms on gunicorn and
  • I use nGinx for static content

So, after I did some research and debugging, this is how I have solved my problem:

In nGinx config , i had this:

location / {
    proxy_pass http://localhost:8000;
}

when DEBUG = False ALLOWED_HOSTS = ['.example.com','.example.com.',] was not working because

get_host() was returning localhost:8000 and should return example.com

This fixed it:

location / {
    proxy_pass http://localhost:8000;
    proxy_set_header Host $http_host;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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