So I installed nginx in digitalocean droplet.. so far so good. But now I can't get a bootstrap template to show, I tried accessing a png file and nothing.

When entering

curl -I http ://

I get..

HTTP/1.1 404 Not Found <br>
Server: nginx/1.4.6 (Ubuntu) <br>
Date: Sun, 03 Jul 2016 10:28:09 GMT <br>
Content-Type: text/html <br>
Content-Length: 177 <br>
Connection: keep-alive <br>

When entering curl -I

I get..

root@ubuntu-nginx-1:~# curl -I <br>
HTTP/1.1 200 OK <br>
Server: nginx/1.4.6 (Ubuntu) <br>
Date: Sun, 03 Jul 2016 10:32:04 GMT <br>
Content-Type: text/html <br>
Content-Length: 612 <br>
Last-Modified: Tue, 04 Mar 2014 11:46:45 GMT <br>
Connection: keep-alive <br>
ETag: "5315bd25-264" <br>
Accept-Ranges: bytes <br>


For whatever reason nginx is giving me a 404 when accessing any directory..

My conf file looks like this..

events {}

http {

    include mime.types;

    server {

        listen 80;
        root /sites/bootstrap;




I'm a complete noob so any help would be gladly appreciated thank you!

  • 1
    Welcome to ServerFault. Nginx has excellent wiki at wiki.nginx.org for any complete noob. For your particular question, you may want to look into the logs (probably in /var/log/nginx/*.log) to understand what's going on. You might also want to include a location block (and possibly a try_files directive inside it too). If you have any trouble formatting questions here, please spend some time at serverfault.com/help/formatting . – Pothi Kalimuthu Jul 3 '16 at 11:45
  • I entered /var/log/nginx/*.log and get -bash: /var/log/nginx/access.log: Permission denied ? – linoa1 Jul 3 '16 at 20:06
  • Your site's home page and the images are okay as of now. How did you solve it? – Pothi Kalimuthu Jul 4 '16 at 8:19
  • I made a super noob mistake.. I was editing the wrong nginx.conf file which was inside my /root/nginx-1.9.15.. instead of editing the /etc/nginx/nginx.conf... lol, now everything is working fine. I'm still getting "Permission denied" when I run /var/log/nginx/access.log, will that be an issue? – linoa1 Jul 5 '16 at 6:16

As pointed in the comment, in your server block, you may want to add the following (below the root line):

location /img/ {

Then reload your config with nginx -s reload and try your curl command again.

  • I managed to get the site working. But I still get 404 Not Found when accessing files.. ? ( works fine) ( gives me 404 Not Found) – linoa1 Jul 3 '16 at 20:08
  • If you've kept your root line as is, it means that you should not need the /sites/bootstrap/ bit to retrieve your image. So what if you do: curl -i http :// ? – David B. Jul 4 '16 at 9:52
  • Fantastic! I can access all files in browser when I remove the /sites/bootstrap/. But, when I run curl -i in terminal I get a mess of code that looks like this.... "%L@.����x3�4>�_R��Q�k���/�`{i��" Any ideas why? – linoa1 Jul 5 '16 at 6:26
  • EDIT: curl i was the issue, I needed to use curl I (capital i).. all good! Thank you David! – linoa1 Jul 5 '16 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.