V
V
Valery Ryaboshapko2014-11-24 18:02:27
Nginx
Valery Ryaboshapko, 2014-11-24 18:02:27

Why is nginx giving files so strangely?

Unfortunately, I won’t give exact quotes from the terminal, but I give a tooth for the authenticity.

$ curl -s http://example.com/some/file.js | md5sum
21c5a6558a2f7197de94ac600f2ccf95 -
$ md5sum some/file.js
a7a12a18fb6bdcc00b88a96db45b418b some/file.js
$ pwd
/var/www/user/data/www/example.com

That is, the problem is that there is a certain file. This file is served by nginx. But the problem is that the file on the disk does not match what nginx gives. No memcahed etc. not enabled in nginx (config below). The domain name resolves correctly. The problem is solved only by restarting nginx. What could be the problem?
$ cat /etc/nginx/nginx.conf 
# Вывод cat немного урезан, в нём описывается около трёх десятков блоков server на разные домены с одиноковым, в принципе, содержимым.
user apache;
worker_processes 12;

error_log  /var/log/nginx/error.log;

pid        /var/run/nginx.pid;

events {
    worker_connections  2048;
}

http {
    server_names_hash_bucket_size 256;
    server_names_hash_max_size    1024;
    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  0;
    keepalive_timeout  65;

    #gzip  on;
    gzip              on;
    gzip_buffers      16 8k;
    gzip_comp_level   4;
    gzip_http_version 1.0;
    gzip_min_length   1280;
    gzip_types        text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp;
    gzip_vary         on;    
    
    # Load config files from the /etc/nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/nginx/conf.d/*.conf;

  include /usr/local/ispmgr/etc/nginx.domain;
  client_max_body_size 2048M;
  log_format isp '$bytes_sent $request_length';
  limit_zone levada_11384 $binary_remote_addr 6400k;

  server {
    server_name example.com www.example.com;
    listen 8.8.8.8;
    set $root_path /var/www/user/data/www/example.com;
    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
      root $root_path;
      access_log /var/www/nginx-logs/user isp;
      access_log /var/www/httpd-logs/example.com.access.log ;
      error_page 404 = @fallback;
    }
    location / {
      proxy_pass http://localhost:81;
      proxy_redirect http://localhost:81/ /;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
    }
    location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ {
      proxy_pass http://localhost:81;
      proxy_redirect http://localhost:81/ /;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
    }
    location @fallback {
      proxy_pass http://localhost:81;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
    }
    include /usr/local/ispmgr/etc/nginx.inc;
  }
}

$ nginx -v
nginx version: nginx/1.0.15

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Sundukov, 2014-11-24
@valerium

Miracles don't happen. nginx is adequate and good enough to be sure that it gives exactly what is asked of it. So it's not configured correctly. I would start by looking at the access log. There you can make sure that he gave the file, gave exactly the one you were looking for, as well as its size. If the situation does not clear up, then cling to strace and watch where it goes for the file.

N
neolink, 2014-11-24
@neolink

Have you tried comparing files? just by size or like this:
show the offset of the first byte that differs, -l - print the differences in detail

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question