Project

General

Profile

nginx proxy blocking file upload viewing

Added by Mitch Pirtle almost 13 years ago

In a nutshell I can fire up redmine using mongrel and surf to :3000 and everything works. If I then proxy to :3000 from nginx, everything works except viewing file uploads (for wiki entries, tracker items, whatever).

Looks like the image requests are getting mangled somewhere in nginx, or in the host config. Ultimately the URL for an uploaded file looks like this:

http://my.website.com:3000/attachments/138/01_indexunliked.jpg
http://my.website.com/attachments/138/01_indexunliked.jpg

Going to the one hosted on my.website.com:3000 works fine, going through my.website.com (nginx) results in a 404.

Please let me know what I can do to figure this out, has been annoying the ** out of me for far too long! :-)

Here's my environment:

NOTE: SourceIndex.new(hash) is deprecated; From /var/www/my.website.com/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:100:in `new'.
About your application's environment
Ruby version              1.8.7 (x86_64-linux)
RubyGems version          1.7.2
Rack version              1.1.2
Rails version             2.3.14
Active Record version     2.3.14
Active Resource version   2.3.14
Action Mailer version     2.3.14
Active Support version    2.3.14
Edge Rails revision       unknown
Application root          /var/www/my.website.com
Environment               production
Database adapter          mysql
Database schema version   20110902000000

About your Redmine plugins
Redmine Light Box plugin                         0.0.1
Redmine Ultraviolet Syntax highlighting plugin   0.0.3
Redmine Github Hook plugin                       0.1.1

This is a debian machine running 64 bits, running nginx 1.0.10:

Linux version 2.6.26-2-amd64 (Debian 2.6.26-26lenny2) () (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 SMP Tue Jan 25 05:59:43 UTC 2011

Here's my relevant bits from my.website.conf:

upstream mongrel_cluster {
  server 127.0.0.1:3000;
}

server {
   server_name  my.website.com;

   access_log  /var/log/nginx/my.website.com-access.log;
   error_log   /var/log/nginx/my.website.com-error.log;

   include proxy.include;
   root /var/www/my.website.com/public;

   location ~* \.(js|css|jpg|jpeg|gif|png)$ {
     if (-f $request_filename) {
       expires 24h;
       break;
     }
   }

   location / {
       try_files $uri/index.html $uri.html $uri @fallback;
   }

   location @fallback {
       proxy_pass              http://mongrel_cluster;
       proxy_connect_timeout   15;
       proxy_redirect          off;
       proxy_set_header        Host    $http_host;
       proxy_set_header        X-Real-IP       $remote_addr;
       proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
       #proxy_set_header       X-Forwarded-Proto       https;
   }

}

Anybody here have this issue, and did you figure it out?


Replies (1)

RE: nginx proxy blocking file upload viewing - Added by doesnot concernyou about 8 years ago

5 years late but maybe someone else has the same issue
-> it's the image cache of nginx

    (1-1/1)