NGINX algumas vezes tem erro (Nenhum arquivo ou diretório)

0

Depois de algum tempo meu servidor nginx terá um erro com relação a arquivos estáticos, estou usando o NGINX em um servidor que serve arquivos estáticos e como proxy para o aplicativo Django em outro servidor.

Eu copio os arquivos estáticos do servidor Django para o servidor NGINX e executo o comando ./manage.py collectstatic .

error.log

2016/12/07 20:36:17 [error] 26548#0: *1359 open() "/home/ws-admin/foo/media/branches/gmap__ndaUhjI.jpg" failed (2: No such file or directory), client: x.x.x.x, server: _, request: "GET /media/branches/gmap__ndaUhjI.jpg HTTP/1.1", host: "www.foo.com", referrer: "http://www.foo.com/"
2016/12/08 21:34:14 [error] 20474#0: *8608 open() "/home/ws-admin/foo/static/js/notify.js" failed (2: No such file or directory), client: x.x.x.x, server: _, request: "GET /static/js/notify.js HTTP/1.1", host: "www.foo.com", referrer: "http://www.foo.com/signup/"

nginx.conf

user ws-admin;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


# TCP/UDP proxy and load balancing block
#
#stream {
    # Example configuration for TCP load balancing

    #upstream stream_backend {
    #    zone tcp_servers 64k;
    #    server backend1.example.com:12345;
    #    server backend2.example.com:12345;
    #}

    #server {
    #    listen 12345;
    #    status_zone tcp_server;
    #    proxy_pass stream_backend;
    #}
#}

sites-enabled / foo

 upstream app_server {
    server x.x.x.x:8000 fail_timeout=0;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name _;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/ws-admin/foo/media;
    }

    # your Django project's static files - amend as required
    location /static {
        alias /home/ws-admin/foo/static;
        expires 365d;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_pass http://app_server;
    }
}

settings.py

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    
por Emad Mokhtar 10.12.2016 / 20:29

0 respostas