-1

When I try to access a file which is named "file" I got the Error 404 - file not found.

I checked on the Server if it exists. Yes it does exist.

I checked if the file is owned by the webuser. Yes it is.

I checked the correct permission. 775 should work, so yes.

The problem is, that the file isn't treated as file. Nginx thinks it is a folder and searches for an index.html file.

2017/09/14 11:26:50 [error] 15085#15085: *3 "/srv/www/myfolder/file/index.html" is not found (20: Not a directory), client: 192.168.1.35, server: , request: "GET /myfolder/file/ HTTP/1.1", host: "example.com", referrer: "http://example.com/myfolder/"

How can I change that ? I also tried with several browsers (FF, Safari) also cURL and wget .. still Error 404

UPDATE 1

 server {

            listen 80 default_server;
            rewrite ^([^.]*[^/])$ $1/ permanent;
            gzip off;

       location /mirror {
                alias /srv/mirror;
                autoindex on;
        }

It is an Debian Mirror - if I comment the rewrite out, I get this Error:

 BZ2_bzread: /var/lib/apt/lists/partial/mirror.com_debian_dists_stretch_main_i18n_Translation-en.bz2 Read error (-5: DATA_ERROR_MAGIC)

If i comment that in Again, it can't find the Release file cause of the redirect ...

SystemCookie
  • 169
  • 1
  • 14

3 Answers3

1

If you want the redirect to not end in a /, you should leave it off the redirect configuration.

In other words, change

        rewrite ^([^.]*[^/])$ $1/ permanent;

to

        rewrite ^([^.]*[^/])$ $1 permanent;
Jenny D
  • 27,358
  • 21
  • 74
  • 110
0

I just fixed this issue on my server. The cause of the error was a symlink.

I just encountered this (not very elucidating) error message on my server's nginx config:

"/path/to/index.html" is not found (20: Not a directory)

After some trial-and-error, I determined that the actual cause was that nginx couldn't access the site's document root because part of the path to the root included a symlink, but I had disable_symlinks on; set in my main nginx.conf file.

Commenting-out the disable_symlinks on; line or changing it to disable_symlinks off; fixes the issue.

See also:

Michael Altfield
  • 525
  • 6
  • 18
0

Hi I can see that your GET request is request: "GET /myfolder/file/ !

If it is a file, the GET request should be without the backslash at the end.

The correct request will be.

request: "GET /myfolder/file

dkakoti
  • 181
  • 1
  • 4
  • Yeah, and i found out why it get's redirected. I have this in my nginx.conf rewrite ^([^.]*[^/])$ $1/ permanent; which makes sense - but i need to exclude the word "file". and don't get the regex correct to exclude the word "file". – SystemCookie Sep 15 '17 at 06:08
  • Open a new question for this issue and include your nginx virtual host configuration in the question, then I can find a way to solve the issue. – Tero Kilkanen Sep 15 '17 at 06:48
  • I've updated the Question, if this is also okay ? – SystemCookie Sep 18 '17 at 08:05