2

I have a subdirectory on my rails app that I want entirely static. My problem is that I am unable to visit /subdirectory/ and have it show index.html, I have to go to /subdirectory/index.html.

How can show the index files for subdirectories? I'm using nginx and rails 2.3.11

wejrowski
  • 439
  • 5
  • 20

1 Answers1

2

you set up what the indexfile is with the index directive described at http://nginx.org/en/docs/http/ngx_http_index_module.html#index

alternatively you could add trying the index.html explicitly to your try_files directive for your subdir location:

location /static-subdir/ {
  try_files $uri $uri/index.html;
}
cobaco
  • 10,224
  • 6
  • 36
  • 33
  • Hmm ok so I got this to work on our dev server. I put the same thing on production and it just shows the rails not found page. Any ideas? The server{} code is virtually the same except different domains, and a couple nginx conf includes. – wejrowski Aug 21 '12 at 20:55
  • 1
    You say it's showing the rails not found page, as opposed to the nginx one. That would indicate it's getting passed to the rails app instead of checking for the static files. Which would indicate something is not quite right with the setup of your locations as the wrong one is getting priority. http://nginx.org/en/docs/http/ngx_http_core_module.html#location spells out in what order location directives are considered. – cobaco Aug 21 '12 at 21:05
  • Hmm ok a little closer. I literally added "mimic1000" after the url string and it at least did something different. I had to change $uri to my folder name but.. then it started doing a rails forward saying that route didn't exist. But the strange thing is when I visit the url manually it shows the file fine.. – wejrowski Aug 21 '12 at 23:19
  • Gah got it, ok looks like nginx is specific about the slashes. – wejrowski Aug 21 '12 at 23:44