worker_processes  1;
error_log logs/error.log;

events {
    worker_connections 1024;
}

http {
    server {
        listen 8080;

        include mime.types;
        charset utf-8;
        default_type text/html;

        try_files $uri $uri/ $uri.html =404;

        # return `/posts/index.html` from `/posts`
        location = /posts {
            rewrite ^ /posts/ break;
        }

        # redirect requests ending in a forward slash
        location ~ ^/(.+)/$ {
            return 302 /$1;
        }

        location /css {
            expires 1h;
            alias css;
        }
    }
}
