Use : nginx,gunicorn,linode for server
Debug=False
When I keep debug=False in production the css file don’t get loaded.I have also build 404.html page.Suppose some one visit mydomain.com/abcd then he/she will get the 404 page which I have designed.Its good.The issue is css file not loaded.
Debug True
When I keep debug=True in the production the css file get loaded.Everything goes right.But when someone visited the mydomain.com/abcd then he/she will get the django defaualt error page.If I keep debug=True in the production everything goes right but I have heard that keeping debug=True in production is not recommended and may cause the security issues in the sites
Currently what I have in my settings.py and nginx cofig are :
settings.py :
DEBUG =True
ALLOWED_HOSTS = ['ip','mydomain.com','www.mydomain.com']
Nginx config file :
server {
server_name mydomain.com www.mydomain.com;
location = /favicon.ico { access_log off; log_not_found off; }
location projectdir/static/ {
autoindex on ;
root /home/user/projectdir;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
Please help me to solve the issue,since I am struggling from past 1 week.
Currently the site is live and css is loaded by keeping debug=True.But I don’t want to have any security issue later.
2
Answers
In settings.py file:
You can simply add like below code:
Try this way and check if this is solves your error
config required in your settings.py
make sure you’ve run the following, so django finds all your static files and puts them in one place
nginx static config should look more like