Pregunta

I want to deliver static assets via a virtual directory, but I'm stuck at the following two problems.

  1. I'm redirected to an URL where nginx wants to add a trailing slash to the file name and
  2. the system thinks that I want a directory listing instead of a single file, resulting in nginx doing the wrong thing.

Example from the error.log file:

2014/04/24 11:21:37 [error] 6808#6952: *15 directory index of "E:/fileserver/intranet/" is forbidden, client: 192.168.110.79, server: intraTest, request: "GET /intraStatic/employees/0C0C3E08-5056-A300-0E2C2FF5D437C6A3.png/ HTTP/1.1", host: "intraTest"

Snippet from my config file:

location ~ /intraStatic/ {
    autoindex  off;
    alias  e:/fileserver/intranet/;
    break;
}

Since the log includes the path mentioned in the alias I know that the location block is not ignored, but I can't access the files in there even though the file system permissions are just fine and the file exists and hasn't been corrupted by anything.

Since Google just responds with results where each one is even more useless than the previous ones I can only hope that someone here can shed some light on the matter.

Thanks in advance for your replies!

¿Fue útil?

Solución 2

Thanks everyone for your replies.

When I was almost frustrated enough to go through the Tomcat server behind one of the commented out applications, it occurred to me to use a more brute force solution, since the suggestions above didn't seem to work in my case.

In the end I renamed the file system folder and went with the following route:

location ~ /intraStatic/ {
    autoindex  off;
    root  e:/fileserver/;
    break;
}

Thanks anyway for taking the time to help me find a solution.

Otros consejos

from ngx_http_core_module:

If a location is defined by a prefix string that ends with the slash character, and requests are processed by one of proxy_pass, fastcgi_pass, scgi_pass, uwsgi_pass, or memcached_pass, then in response to a request with URI equal to this string, but without the trailing slash, a permanent redirect with the code 301 will be returned to the requested URI with the slash appended. If this is not desired, an exact match of the URI and location could be defined like this:

location /user/ {
    proxy_pass http://user.example.com;
}

location = /user {
    proxy_pass http://login.example.com;
}

so try:

location ~ /intraStatic {
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top