Path: blob/main/xml/en/docs/http/ngx_http_referer_module.xml
1 views
<?xml version="1.0"?>12<!--3Copyright (C) Igor Sysoev4Copyright (C) Nginx, Inc.5-->67<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">89<module name="Module ngx_http_referer_module"10link="/en/docs/http/ngx_http_referer_module.html"11lang="en"12rev="2">1314<section id="summary">1516<para>17The <literal>ngx_http_referer_module</literal> module is used to block18access to a site for requests with invalid values in the19<header>Referer</header> header field.20It should be kept in mind that fabricating a request with an appropriate21<header>Referer</header> field value is quite easy, and so the intended22purpose of this module is not to block such requests thoroughly but to block23the mass flow of requests sent by regular browsers.24It should also be taken into consideration that regular browsers may25not send the <header>Referer</header> field even for valid requests.26</para>2728</section>293031<section id="example" name="Example Configuration">3233<para>34<example>35valid_referers none blocked server_names36*.example.com example.* www.example.org/galleries/37~\.google\.;3839if ($invalid_referer) {40return 403;41}42</example>43</para>4445</section>464748<section id="directives" name="Directives">4950<directive name="referer_hash_bucket_size">51<syntax><value>size</value></syntax>52<default>64</default>53<context>server</context>54<context>location</context>55<appeared-in>1.0.5</appeared-in>5657<para>58Sets the bucket size for the valid referers hash tables.59The details of setting up hash tables are provided in a separate60<link doc="../hash.xml">document</link>.61</para>6263</directive>646566<directive name="referer_hash_max_size">67<syntax><value>size</value></syntax>68<default>2048</default>69<context>server</context>70<context>location</context>71<appeared-in>1.0.5</appeared-in>7273<para>74Sets the maximum <value>size</value> of the valid referers hash tables.75The details of setting up hash tables are provided in a separate76<link doc="../hash.xml">document</link>.77</para>7879</directive>808182<directive name="valid_referers">83<syntax>84<literal>none</literal> |85<literal>blocked</literal> |86<literal>server_names</literal> |87<value>string</value>88...</syntax>89<default/>90<context>server</context>91<context>location</context>9293<para>94Specifies the <header>Referer</header> request header field values95that will cause the embedded <var>$invalid_referer</var> variable to96be set to an empty string.97Otherwise, the variable will be set to “<literal>1</literal>”.98Search for a match is case-insensitive.99</para>100101<para>102Parameters can be as follows:103<list type="tag">104105<tag-name><literal>none</literal></tag-name>106<tag-desc>107the <header>Referer</header> field is missing in the request header;108</tag-desc>109110<tag-name><literal>blocked</literal></tag-name>111<tag-desc>112the <header>Referer</header> field is present in the request header,113but its value has been deleted by a firewall or proxy server;114such values are strings that do not start with115“<literal>http://</literal>” or “<literal>https://</literal>”;116</tag-desc>117118<tag-name><literal>server_names</literal></tag-name>119<tag-desc>120the <header>Referer</header> request header field contains121one of the server names;122</tag-desc>123124<tag-name>arbitrary string</tag-name>125<tag-desc>126defines a server name and an optional URI prefix.127A server name can have an “<literal>*</literal>” at the beginning or end.128During the checking, the server’s port in the <header>Referer</header> field129is ignored;130</tag-desc>131132<tag-name>regular expression</tag-name>133<tag-desc>134the first symbol should be a “<literal>~</literal>”.135It should be noted that an expression will be matched against136the text starting after the “<literal>http://</literal>”137or “<literal>https://</literal>”.138</tag-desc>139140</list>141</para>142143<para>144Example:145<example>146valid_referers none blocked server_names147*.example.com example.* www.example.org/galleries/148~\.google\.;149</example>150</para>151152</directive>153154</section>155156157<section id="variables" name="Embedded Variables">158159<para>160<list type="tag">161162<tag-name id="var_invalid_referer"><var>$invalid_referer</var></tag-name>163<tag-desc>164Empty string, if the <header>Referer</header> request header field165value is considered166<link id="valid_referers">valid</link>, otherwise “<literal>1</literal>”.167</tag-desc>168169</list>170</para>171172</section>173174</module>175176177