Nginx configuration for the site.

A few people were asking to see the nginx configuration used on my website. Here it is with a few comments to help it all make sense. I don't claim to be an nginx expert, because I've only recently switched to it from Apache. Please feel free to offer any advice and suggestions.

This first server block is for redirect requests from www.daylerees.com to daylerees.com. It looks nicer :)

    server {

            listen          80;
            server_name     www.daylerees.com;

            rewrite ^(.*) //daylerees.com$1 permanent;

    }

This is the main server block for my markdown blog. I've added inline comments to help explain what's going on.

    server {

            listen          80;
            server_name     daylerees.com;

            access_log      /var/log/nginx/daylerees.com/access.log;
            error_log       /var/log/nginx/daylerees.com/error.log;
            rewrite_log     on;

            root            /var/www/daylerees.com/public;
            index           index.php;

            # Added cache headers for images, quick fix for cloudfront.

            location ~* \.(png|jpg|jpeg|gif)$ {

                    expires 30d;
                    log_not_found off;

            }

            # Only 3 hours on CSS/JS to allow me to roll out fixes during
            # early weeks.

            location ~* \.(js|css|ico)$ {

                    expires 3h;
                    log_not_found off;

            }

            # Heres my redirect, try normal URI and then our Laravel urls.

            location / {

                    try_files $uri $uri/ /index.php?$query_string;

                    # A bunch of perm page redirects from my old
                    # site structure for SEO purposes. Not interesting.

                    include /etc/nginx/templates/redirects;

            }


            # Look below for this. I decided it was common to Laravel
            # sites so put it in an extra template.

            include         /etc/nginx/templates/laravel4;

    }

And here's the contents from the /etc/nginx/templates/laravel4 include mentioned above.

    # Rewrite for content.

    if (!-d $request_filename) {

            rewrite ^/(.+)/$ /$1 permanent;

    }


    location ~* \.php$ {

            # Server PHP config.
            fastcgi_pass                    unix:/var/run/php5-fpm.sock;
            fastcgi_index                   index.php;
            fastcgi_split_path_info         ^(.+\.php)(.*)$;

            # Typical vars in here, nothing interesting.

            include                         /etc/nginx/fastcgi_params;
            fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

    location ~ /\.ht {

            # Hells no, we usin nginx up in this mutha. (deny .htaccess)
            deny all;

    }

I hope someone finds this useful!