繁体   English   中英

如何使用Nginx阻止自定义URL模式

[英]How to block custom url pattern using nginx

我试图阻止从nginx中的URL模式读取web.xml,为此我尝试了它对我不起作用

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

这是包含web.xml的URL模式

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=

这对我有用

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

这样尝试

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

使用此正则表达式位置:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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