Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm following the html5boilerplate nginx setup for the most part, but everything keeps breaking when I include expires.conf.

HTML5BP for Nginx setup: https://github.com/h5bp/server-configs/tree/master/nginx

I've changed only a few very minor things which I'll put below. When in include conf/expires.conf however everything returns 404.

As a sidenote, I don't think it's just HTML5BP either.. i also followed this guide and images also broke (under the heading for Nginx tip #5 static assets expire).

location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
    access_log        off;
    log_not_found     off;
    expires           360d;
}

I'm using nginx on a server behind an EC2 elastic load balancer.

Here is my /etc/nginx/sites-enabled/example.conf:

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /var/www/html/example.com;
        index  index.html index.htm;
    }

    # Specify a charset
    charset utf-8;

    # Custom 404 page
    error_page 404 /404.html;

    include conf/base.conf;
}

One odd thing i noticed is that if i check errors.log it has this..

2013/03/25 04:38:45 [error] 17920#0: *1 open() "/usr/share/nginx/html/index.html" failed (2: No such file or directory)

Yet I changed the directory away from /usr/share/nginx/html, so I have no idea why its looking there?

share|improve this question

1 Answer 1

The problem was I changed my nginx root path from /usr/share/nginx or whatever it is by default to /var/www/html/site.com

That means the root command should have happened in my server directive instead of my location directive so that it trickles down. Because it couldnt see any root defined it was using the binary default

http://docs.ngx.cc/en/latest/topics/tutorials/config_pitfalls.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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