Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

433
Vistas
Django, serving static files with nGinx gives error 404

I can't serve static files through nGinx and I am getting 404 instead. I can see the error (shown in the error.log), I just can't see how to fix it.

urls.py

urlpatterns += patterns('', (
        r'^static/(?P<path>.*)$',
        'django.views.static.serve',
        {'document_root': 'static'}
))

settings.py

STATIC_ROOT =  os.path.join(PROJECT_DIR, "staticfiles/")
STATIC_URL = '/static/'

DEBUG=False

(did a collectstatic and all static files are now in 'staticfiles/')

nginx configuration

server { 
    listen 80; 
    server_name my_ip;  
    location = /favicon.ico { access_log off; log_not_found off; } 

    location /static/ {
        root /home/project/project/project/staticfiles;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/project/project/project.sock;
    }
}

base.html

{% load staticfiles %}
<link rel="stylesheet" href="{% static '/css/main.css' %}">

and this is the log

error.log

2017/04/09 10:57:40 [error] 4719#4719: *182 open() "/home/project/project/project/staticfiles/static/images/home-lock.png" failed (2: No such file or directory)

("static/" is added in the static url and I can't see why)

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Try this

location /static/ {
    alias /home/project/project/project/staticfiles;
}
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda