location ~ ^/awstats {
    rewrite ^ /cgi-bin/awstats.pl;
}
location ^~ /awstatsicons {
    alias /usr/share/awstats/icon/;
    access_log off;
}
location ^~ /awstatsclasses {
    alias /usr/share/java/awstats/;
    access_log off;
}

location ~ ^/cgi-bin/.*\.(cgi|pl|py|rb) {
    gzip off;
    include         fastcgi_params;
    fastcgi_pass    php;
    fastcgi_index   cgi-bin.php;
    fastcgi_param   SCRIPT_FILENAME    /etc/nginx/cgi-bin.php;
    fastcgi_param   SCRIPT_NAME        cgi-bin.php;
    fastcgi_param   X_SCRIPT_FILENAME  /usr/lib$fastcgi_script_name;
    fastcgi_param   X_SCRIPT_NAME      $fastcgi_script_name;
    fastcgi_param   REMOTE_USER        $remote_user;
}
