location /nagiosbp {
    alias   /usr/local/nagiosbp/share;
    auth_basic              "Icinga Access";
    auth_basic_user_file    /usr/local/icinga/etc/htpasswd.users;
}

location ~ /nagiosbp/(.*)\.cgi$ {
    root /usr/local/nagiosbp/sbin;
    rewrite ^/nagiosbp/cgi-bin/(.*)\.cgi /$1.cgi break;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
    fastcgi_index index.php;
    fastcgi_param  SCRIPT_FILENAME  /usr/local/nagiosbp/sbin$fastcgi_script_name;
    auth_basic              "Icinga Access";
    auth_basic_user_file    /usr/local/icinga/etc/htpasswd.users;
    fastcgi_param  AUTH_USER          $remote_user;
    fastcgi_param  REMOTE_USER        $remote_user;
}

