Warm tip: This article is reproduced from serverfault.com, please click

其他-Magento Enterprise 1.14.2通过Nginx阻止RSS

(Magento Enterprise 1.14.2 Block rss via nginx)

发布于 2021-03-19 08:33:26

我已经尝试了几种在网络上找到的变体,但是它似乎不起作用。我想阻止这些网址,因为它们出现在magento安全扫描中。

domain.com/index.php/rss/catalog/notifystock
domain.com/index.php/rss/catalog/review
domain.com/index.php/rss/order/new

domain.com/rss/catalog/notifystock
domain.com/rss/catalog/review
domain.com/rss/order/new

我尝试过的是:

location ^~ /rss/order/new {
  deny all;
}

location ~ ^/index.php/?rss/ {
   deny all; 
}

location ~ ^/rss/ {
   deny all;
}

location ~* ^/?(index.php?)?rss/(order/new|catalog/notifystock|catalog/review) { return 403; }

有些代码只能阻止没有index.php的url

Questioner
Christian Young
Viewed
0
Richard Smith 2019-01-22 22:31:48

一次查看规则...

location ^~ /rss/order/new { deny all; }

这将阻止你的问题中的第6个URI。

^~修饰符一起使用前缀位置是明确的,并且比正则表达式更有效。你可以使用以下命令阻止问题中的所有六个URI:

location ^~ /index.php/rss/catalog/notifystock { deny all; }
location ^~ /index.php/rss/catalog/review { deny all; }
location ^~ /index.php/rss/order/new { deny all; }
location ^~ /rss/catalog/notifystock { deny all; }
location ^~ /rss/catalog/review { deny all; }
location ^~ /rss/order/new { deny all; }

或者,对于更通用的规则,所有/rss/URI都使用:

location ^~ /index.php/rss/ { deny all; }
location ^~ /rss/ { deny all; }

location ~ ^/index.php/?rss/ { deny all; }

这是一个正则表达式位置,需要放置在任何有冲突的正则表达式位置块上方(例如:)location ~ \.php有关详细信息,请参见此文档

?之后的/是不必要的,因为没有要求,以匹配URI等/index.phprss

如果在你的配置中放置足够高的位置,它将阻止你问题中的前三个URI。


location ~ ^/rss/ { deny all; }

这也是一个正则表达式位置,需要放置在任何有冲突的正则表达式位置块上方。

如果在你的配置中放置的位置足够高,它将阻止你问题中的最后三个URI。

与前面的规则一起,应该阻止问题中的所有URI,以及更多。


location ~* ^/?(index.php?)?rss/(order/new|catalog/notifystock|catalog/review) { return 403; }

这也是一个正则表达式位置,需要放置在任何有冲突的正则表达式位置块上方。

不会匹配在你的问题前三的URI,因为它缺少/之间.phprss

尝试:

location ~* ^(/index.php)/rss/(order/new|catalog/notifystock|catalog/review) { return 403; }

该规则需要放置在任何有冲突的正则表达式定位块(尤其是该location ~ \.php块)上方