我使用 Nginx 作为 Web 服务器。
有什么方法可以提取http_referer_hostname
并放入访问日志中。
例如:如果$http_referer
是"http://example.com/?somedata"
,如何仅将主机名部分(example.com
)记录到该access.log
行?
我使用 Nginx 作为 Web 服务器。
有什么方法可以提取http_referer_hostname
并放入访问日志中。
例如:如果$http_referer
是"http://example.com/?somedata"
,如何仅将主机名部分(example.com
)记录到该access.log
行?
使用地图:
map $http_referer $http_referer_hostname {
~^.*://(.+)/.*$ $1;
}
所需的结果将存储在 $http_referer_hostname