1

Answer in comments, I didn't have the correct permissions set.

Moved from Stack Overflow

My website, https://davisstanko.com returns a 404 error for everything other than index.html. This includes files such as pictures which can be confirmed in the network tab of inspect element.

The code, available at https://github.com/DavisStanko/davisstanko.com works fine locally. This has lead me to believe the problem lies with nginx.

My website is hosted on a VPS from Vultr running Debian 11. It has ports 80 and 443 open.

My PC is running Manjaro and I'm using rsync to send the files to the VPS.

When running ls -l on the server, all files including those giving the 404 error return -rw-r--r--.

Below is the part of my nginx config that I believe may be relevant:

server {
        server_name davisstanko.com ;
        root /var/www/davisstanko/ ;
        index index.html index.htm index.nginx-debian.html ;
        location / {
                try_files $uri $uri/ =404 ;
                autoindex on ;
       }

Access log: https://pastebin.com/fVNzNvKL

Error log: https://pastebin.com/1ynNggMw

If you need me to post more information please let me know.

Davis Stanko
  • 11
  • 1
  • 6
  • Could you try moving the `try_files` directive out of the `location { }` block? I have a suspicion that the $uri variable wont work inside this block. Also please provide access and error logs. – mashuptwice Mar 01 '22 at 12:39
  • Check that the user running the nginx process has read/execute access to the directories `html` and `images` – Richard Smith Mar 01 '22 at 13:49
  • @RichardSmith both of those directories return drwx------ when I run ls -l – Davis Stanko Mar 01 '22 at 17:06
  • @mashuptwice I move the try files line out of location into server and nothing changed. I'll update my post with those logs asap. – Davis Stanko Mar 01 '22 at 17:07
  • `drwx------` means that only the owner can read the files contained within. Who is the owner and is it the same as the process that runs nginx - probably not. – Richard Smith Mar 01 '22 at 17:34
  • @RichardSmith Changing perms fixed it!!! I could have sworn I already gave them the correct perms but I guess not. Thanks! – Davis Stanko Mar 01 '22 at 17:55
  • @DavisStanko You might want to add an answer to your question by yourself. This may helps others, as the question gets marked as answered – mashuptwice Mar 01 '22 at 22:40

1 Answers1

0

Although running ls -l on the server returned -rw-r-r-- for all files including those giving the 404 error the directories themselves did not have the proper permissions. Changing the directories permissions to allow the web server to display these files fixed it.

Davis Stanko
  • 11
  • 1
  • 6