hello this is my nginx /etc/nginx/sites-available/myproject file
server {
listen 80;
server_name x.x.x.x;
access_log /var/log/nginx/core.log;
location /static/ {
alias ???????;
}
location / {
proxy_pass x.x.x.x:8000;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
in the settings.py file i have:
STATIC_URL = ‘static/’
if DEBUG:
STATICFILES_DIRS = (os.path.join(BASE_DIR, ‘static’),)
else:
STATIC_ROOT = os.path.join(BASE_DIR, ‘static’)
What i have to write in the nginx file because i’m not able to get any static contents
Thanks
regards
Set STATIC_ROOT to a directory outside your project, that nginx will have access to. (We use /var/www/<project_name>
as the basic pattern for our deployments.)
Set your alias to that directory, whatever it is.
Then remember to run collectstatic
.
Thanks, i have done and it work, i don’t understand one think, suppose that my site is : www.my_site.com
Why i can see the application running only if i point to www.my_site.com:8000 and not to my_site.com
Thanks
Then you’ve got something else wrong. Check your nginx logs.
Side note: If you’re going to ask for further assistance on this issue, then you will need to post the actual nginx configuration file(s) involved. Do not edit, redact, simplify, or otherwise alter the contents.