Sécuriser vos Vhosts

Uniquement les requêtes GET HEAD et POST sont autorisé

if ($request_method !~ ^(GET|HEAD|POST)$ ) {
    return 444;
}

Pour ne pas loger les accès aux fichiers favicon.ico et robots.txt

location = /favicon.ico {
    log_not_found off;
    access_log off;
}
location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

L’accès aux fichiers caché peuvent être dangereux tel qu’un .bash_history contant un mot de passe tapé par erreur ou un .my.cnf avec un compte MySQL, l’accès a tous les fichiers caché est donc interdit :

location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
}

Quelque limite pour éviter les Buffer Overflows

client_body_buffer_size  1K;
client_header_buffer_size 1k;
client_max_body_size 1m;
large_client_header_buffers 2 1k;

Dans le cas ou un petit malin essaye de vous faire un référencement douteux

if ( $http_referer ~* (babes|forsale|girl|jewelry|love|nudit|organic|poker|porn|sex|teen) )
{
    return 403;
}

Suggestions de lecture :

comments powered by Disqus