I can't open a static file with NGiNX root function

jnbdz asked:

I am trying to open a static file with root function. Here is my NGiNX config:

location = /test {
            root    /var/53c74dc1c284ff0d63b019fd736f2c7965939e0452104120130821064016.png;
    }

I get this error in my browser:

404 Not Found

Also it does not seem to produce any errors in the NGiNX error logs.

I am using Ubuntu 12.

And I am using NGiNX version 1.2.7.

My answer:


If you’re trying to serve a single, specific file with the URI given for that location, use alias instead of root.

location = /test {
    default_type image/png;
    alias /var/53c74dc1c284ff0d63b019fd736f2c7965939e0452104120130821064016.png;
}

Loading http://www.example.com/test will then serve the named file.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.