简体   繁体   中英

How to block custom url pattern using nginx

Im trying to block read of web.xml from the URL pattern in nginx for this i tried this it doesn't work for me

location ~* \web.xml$ {
return 404;
 }

This is the URL pattern which contain web.xml

https://example.com/group/model?p_p_id=MYWAR_INSTANCE&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=%2FWEBINF%2Fweb.xml&p_p_cacheability=cacheLevelage&p_p_col_id=column2&p_p_col_count=1&repaintAll=1&sh=900&sw=1440&cw=1425&ch=246&vw=1144&vh=1&fr=

This Work for me

if ($args ~* "/?web.xml") {
        rewrite ^ /group/guest last;
    }

try like this

location ^~ /web.xml {
return 404;
 }

Use this regexp location:

location ~* ^(.*)web.xml(.*)$ {
    return 404;    
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM