server {
    listen 80;
    server_name localhost;

    root   /srv/http;
    index  index.php;

    # This catches requests other than /CGP/rrd/ and PHP (see below)
    location /CGP/ {
        gzip on;
        gzip_types "application/javascript text/css";
        # The static files do not change often, cache hint 1 month
        expires 1M;
    }

    # Assume that CGP is located at /srv/http/CGP/, directly serve the RRD data
    # files for use with the canvas graph type. Add compression to reduce data
    # usage by 70% - 80%.
    location /CGP/rrd/ {
        alias /var/lib/collectd/rrd/;
        gzip on;
        gzip_types "*";
        # Cache hint: browser can recheck after 10 minutes
        expires 10m;
        #gzip_comp_level 3;
    }

    # Process PHP files through PHP-FPM
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass   unix:/run/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # Disallow access to hidden files and directories (such as .git/)
    location ~ /\. {
        deny all;
    }
}
