Welcome! Log In Create A New Profile

Advanced

Static file serving only works if root is a subfolder under public

July 05, 2012 11:50PM
I am trying to serve static cache files using nginx. There are index.html files under the rails_root/public/cache directory. I tried the following configuration first, which doesn't work:


root <%= current_path %>/public;
try_files /cache$uri/index.html /cache$uri.html @rails;

Accessing the root / gives this error:

[error] 4056#0: *13503414 directory index of "(...)current/public/" is forbidden, request: "GET / HTTP/1.1"

I then tried

root <%= current_path %>/public/cache;
try_files $uri/index.html $uri.html @rails;

And to my surprise this works.

---

The permissions of the folders are:

775 public
755 cache
644 index.html

The thing is that my favicon sitting under public/ is served correctly:

# asset server
server {
listen 80;
server_name assets.<%= server_name %>;
expires max;
add_header Cache-Control public;
charset utf-8;
root <%= current_path %>/public;
}

So, why is it that I can do the latter not the former( since they point to the same location)? Thanks.
Subject Author Posted

Static file serving only works if root is a subfolder under public

lulalala July 05, 2012 11:50PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 173
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready