mardi 5 mai 2015

Same regex behaving diffrently in Apache and Nginx

I'm trying to covert 5G Blalclist to from Apache(.htaccess) to Nginx(.conf). There is a line in .htaccess that is causing problem:

<IfModule mod_alias.c>  
    RedirectMatch 403 (\,|\)\+|/\,/|\{0\}|\(/\(|\.\.\.|\+\+\+|\||\\\"\\\")  
</IfModule>

I have converted it to .conf as follows:

Code included in http block

map $request_uri $bad_uri {  
    default 0;  
    "~*(\,|\)\+|/\,/|\{0\}|\(/\(|\.\.\.|\+\+\+|\||\\\"\\\")" 1;  
}  

Code included in server block

if ($bad_uri) {  
    return 403;  
}  

As far as I know both Apache and Nginx use perl regex so no change should be required when converting from former to the latter. However, following URI is giving 403 on Nginx but working fine on Apache:

http://ift.tt/1ABaLZy
http://ift.tt/1GO3zeW

Aucun commentaire:

Enregistrer un commentaire