404 Nginx error

February 7, 2018 8.8k views
Nginx

I am trying to make a CS:GO site. Well when i try to goto the website i get the dreaded 404 error. I cannot figure this out. I am fairly new to digital ocean. This is a paste of my Nginx errors. https://pastebin.com/9ftgR002 please let me know how to fix this.

1 comment
  • @kobefrench03 we need more information how did you create the site? What tutorial did you follow?

    According to the logs you don’t have the proper permissions for /var/www/html/public try this command to give read permissions to others chmod o+r /var/www/html/public

    Hope this helps.

1 Answer

@kobefrench03

The directory index error you’re seeing is most likely the result of a missing index ...; directive in your server block or the nginx.conf file. The index directive needs to match the language that you’re serving.

For example, if I were serving a WordPress site, I’d want to have something such as:

server {
    listen 80;
    server_name domain.com www.domain.com;

    root /path/to/public_html;

    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        ...
        ...
        ...
    }
}

While the above is not a complete example, it shows where the index directive may be placed to help prevent that error. You can also modify the index directive in /etc/nginx/nginx.conf under the http block and add it there.

Under http it’s global, thus affects all server blocks and will help redundancies.

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!