Nginx Http引用主机

问题描述 投票:3回答:1

我正在使用Nginx作为Web服务器。

是否有任何方法可以提取“ http Referer host”并将其放入访问日志。

例如:如果http_referer为“ http://example.com/?somedata”:如何仅将主机部分(example.com)登录到accesslog行?

我正在寻找解决方案,但没有发现任何有用的东西。

nginx http-headers http-referer access-log
1个回答
0
投票

使用map

map $http_referer_hostname $http_referer {
    ~^.*://(.+)/.*$ $1;
}

所需的结果将存储在$ http_referer_hostname中

© www.soinside.com 2019 - 2024. All rights reserved.