使用 nginx 代理将 X-Robots-Tag 标头添加到某个位置

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

我有一个 WordPress 网站,在带有 apache 的服务器上运行,前面有一个 nginx 作为代理。

该网站有一个插件,可以将小部件中的电报频道显示为 iframe,我想在 google 搜索结果中排除此 iframe 的结果。

我尝试将此配置添加到nginx。

 location ~ /wptelegram { add_header X-Robots-Tag "noindex, nofollow, noarchive, nosnippet"; }

问题是,现在 iframe 显示起始页面,而不是实际的电报小部件内容。

nginx proxy http-headers nginx-config x-robots-tag
1个回答
0
投票

我通过将代理配置从代理位置重复到此位置解决了这个问题。

location ~ /wptelegram {
    add_header X-Robots-Tag "noindex, nofollow, noarchive, nosnippet";
    proxy_pass https://111.111.111.111:7081;
    proxy_hide_header upgrade;
    proxy_set_header Host             $host;
    proxy_set_header X-Real-IP        $remote_addr;
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
    access_log off;
    proxy_cache_key "$scheme$request_method$host$request_uri";
    proxy_no_cache $no_cache $http_pragma $http_authorization $arg_nocache;
    proxy_cache_bypass $no_cache $http_pragma $http_authorization $arg_nocache;
    proxy_cache example.com_proxy;
    proxy_cache_valid "5";
    proxy_cache_use_stale http_500 http_502 http_503 http_504 updating;
    proxy_cache_background_update on;
}
© www.soinside.com 2019 - 2024. All rights reserved.