Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Nov 28, 2012 5:06 pm 
Offline
Newbie

Joined: Mon Nov 26, 2012 6:31 am
Posts: 3
Hi all,

I am having an odd problem with serving images from a nginx server. on a first load the images often hang for ages until the server times outs, then on reload they get served in an instant. you can see it below in the wget log, first tries to load then gets stuck half way in between then restarts and the file loads in an instant. If I load a page with 20 images in the browser often images never finish to load.

Code:
--2012-11-28 20:42:47--  http://images.thomastraum.com/images/tumblr_me66gfgahO1qzt15co1_500.jpg
Resolving images.thomastraum.com... 178.79.178.99
Connecting to images.thomastraum.com|178.79.178.99|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 147449 (144K) [image/jpeg]
Saving to: `tumblr_me66gfgahO1qzt15co1_500.jpg'

55% [=============================================================================================================================>                                                                                                       ] 81,640      --.-K/s   in 65s     

2012-11-28 20:43:52 (1.23 KB/s) - Connection closed at byte 81640. Retrying.

--2012-11-28 20:43:53--  (try: 2)  http://images.thomastraum.com/images/tumblr_me66gfgahO1qzt15co1_500.jpg
Connecting to images.thomastraum.com|178.79.178.99|:80... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 147449 (144K), 65809 (64K) remaining [image/jpeg]
Saving to: `tumblr_me66gfgahO1qzt15co1_500.jpg'

100%[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++======================================================================================================>] 147,449     --.-K/s   in 0.05s   

2012-11-28 20:43:53 (1.24 MB/s) - `tumblr_me66gfgahO1qzt15co1_500.jpg' saved [147449/147449]


There is no traffic on the server as its just for development at the moment, I am using nginx as a proxy in front of a node js / express site, here is my conf

Code:

#user  nobody;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  10480;
}


http {
    include       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/logs/nginx.log  main;

    sendfile        on;
    tcp_nopush     on;

    #keepalive_timeout  0;
    #keepalive_requests 10000;
    keepalive_timeout  65;
    keepalive_disable none;

    gzip  on;
    gzip_comp_level 6;
    gzip_vary on;
    gzip_min_length  1000;
    gzip_proxied any;
    gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_buffers 16 8k;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

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

        location / {
            root   html;
            index  index.html index.htm;
        }
    }
}



then i have a second conf for my node site:

Code:


upstream images_upstream {
        server 127.0.0.1:3000;
}


server {
        listen 80;
        server_name images.thomastraum.com images;
        access_log /var/log/nginx/images.log;

        location ~  \.(jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ {
          root /home/tommi/sites/now-images-manager/public;
          access_log off;
          expires 30d;
        }

        location / {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_set_header X-NginX-Proxy true;

          proxy_pass http://images_upstream/;
          proxy_redirect off;
        }
}



judging from some googling I am not the only one with this problem but different suggestions I tried all dont seem to work. Any help greatly appreciated!


Top
   
PostPosted: Thu Nov 29, 2012 4:00 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
According to your wget you're getting a .jpg file however .jpg isn't in your location directive, .jpeg is so your request is bing passed upstream to node.

You might want to consider using location /images or try files instead

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group