I’m very new in nginx server configuration. I have a problem serving files under subdirectories on public directory.
Example, files under; rails_app/public/uploads/client/2/image/7/ directory or rails_app/public/picture/ directory are not served
but i have no problems with: rails_app/public/webcam.swf
is like somehow subdirectories are not serve.
my production.rb file
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
only if i set serve_static_assets to true i have no problems
my nginx configuration:
upstream thin {
server '127.0.0.1:3000';
server '127.0.0.1:3001';
server '127.0.0.1:3002';
server '127.0.0.1:3003';
server '127.0.0.1:3004';
}
server {
listen 80 default deferred;
# server_name example.com;
root /home/user/appname/public;
location ^~ /assets/ {
root /home/user/appname/public;
gzip_static on;
expires max;
add_header Cache-Control public;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://thin;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
can you help me with this configuration?
Thanks in advance.
I think the issue is that your
location /block is catching your dynamic requests as well as your non-asset static requests. Try this config (note the try_files line):