Nginx anti-theft chain configuration tutorial

  
 

Judge whether a Requester can effectively prevent theft. This function can be implemented by using the corresponding HTTP Referer module (HTTP Referer) of nginx. This module can be disabled when the Referer field of a request header contains some incorrect fields. This request accesses the site. This header can be arbitrarily forged. Therefore, the use of this module does not block these requests 100%. The vast majority of rejected requests come from some typical browsers. It can be considered that these typical browsers cannot provide a "Referer" head. Even those that are correct. Here's an example:
location /photos/{ valid_referers none blocked www.mydomain.com mydomain.com; if ($invalid_referer) { return 403; } }

There is only one important directive valid_referers: this directive is in the referer header Based on the value assigned to the $invalid_referer variable, the value is 0 or 1. You can use this command to implement the anti-theft chain function. If there is no value of the Referer header in the valid_referers list, $invalid_referer will be set to 1 (see the previous example). The parameter can be of the form: none means that the Referer header does not exist. Block means to pretend the Referer header according to the firewall, such as: “Referer: XXXXXXX”. Server_names is a list of one or more servers. You can use the “*” wildcard in the name after version 0.5.33.

Copyright © Windows knowledge All Rights Reserved