IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    /.well-known/traffic-advice" failed (2: No such file or directory), client: 关于这个问题

    米粒在线发表于 2024-12-30 02:24:19
    love 0
    遇到了这个错误日志:。。。。。/.well-known/traffic-advice" failed (2: No such file or directory), client: 。。。。。以下是折腾记录。

    问题分析

    1. 请求路径:
      • 客户端请求了 /.well-known/traffic-advice,这是一个标准的 URI 路径,通常用于提供特定的服务或协议。
    2. 文件不存在:
      • 服务器未能找到该路径下的文件,导致出现错误。

    解决方案

    1. 创建缺失的文件:
      • 如果您需要这个文件来支持某些功能(例如,流量建议),请创建一个空的或包含必要内容的文件:
        touch /www/wwwroot/网站目录/.well-known/traffic-advice
    2. 检查配置:
      • 确保您的服务器配置允许访问 /.well-known/ 路径。某些情况下,可能需要在 Nginx 或 Apache 配置中进行调整,以允许访问该目录。
    3. 忽略无关请求:
      • 如果这个请求不影响您的网站功能,并且您不需要处理这种类型的请求,可以选择忽略这些错误。定期监控日志,以确保没有其他重要问题。
    4. 设置重定向(可选):
      • 如果您希望将此请求重定向到其他有效的 URL,可以在服务器配置中添加重定向规则。

    解决步骤

    1. 创建 traffic-advice 文件:
      • 在 /.well-known/ 目录下创建一个名为 traffic-advice 的文件,内容如下:
        [{
          "user_agent": "prefetch-proxy",
          "google_prefetch_proxy_eap": {
            "fraction": 1.0
          }
        }]
        
    2. 设置 MIME 类型:
      • 您需要确保服务器返回正确的 MIME 类型。根据您使用的服务器类型,您可以选择以下配置:
      • 对于 Apache: 在 .htaccess 文件中添加以下行:
        RewriteRule ^\.well-known/traffic-advice$ - [T=application/trafficadvice+json,END]
        
      • 对于 Nginx: 在 Nginx 配置文件中添加以下内容:
        location /.well-known/traffic-advice {
            types { } default_type "application/trafficadvice+json; charset=utf-8";
        }
        

    这些是参考修改的原文:

    Googlebot with name "Chrome Privacy Preserving Prefetch Proxy" tries to find instructions if it can preload your website for the user surfing on Chrome (Chrome thinks, for example, the link to your website is going to be clicked on).

    名为“Chrome Privacy Preserving Prefetch Proxy”的 Googlebot 会尝试查找说明,以确定它是否可以为在 Chrome 上冲浪的用户预加载您的网站(例如,Chrome 认为指向您网站的链接将被点击)。

    Basically what we, webmasters, are interested in is to get rid of 404s caused by this feature. The most simplest way is to create the file traffic-advice (without any extension) in the directory .well-known with the content:
    基本上,我们网站管理员感兴趣的是摆脱由此功能引起的 404。最简单的方法是在 .well-known 目录中创建文件 traffic-advice(不带任何扩展名),其内容为:

    [{
      "user_agent": "prefetch-proxy",
      "google_prefetch_proxy_eap": {
        "fraction": 1.0
      }
    }]
    

    Problem is that the bot requires a specific MIME type. On Apache, you can add these lines to the main .htaccess file:
    问题是机器人需要特定的 MIME 类型。在 Apache 上,您可以将以下行添加到主 .htaccess 文件中:

    RewriteRule ^\.well-known/traffic-advice$ - [T=application/trafficadvice+json,END]
    

    On Nginx you can alter your config with these lines:
    在 Nginx 上,您可以使用以下几行更改您的配置:

    # Private Prefetch Proxy
    # https://developer.chrome.com/blog/private-prefetch-proxy/
    location /.well-known/traffic-advice {
       types { } default_type "application/trafficadvice+json; charset=utf-8";
    }
    

    More info or advanced Nginx config can be found from the source.
    更多信息或高级 Nginx 配置可以从源中找到。



沪ICP备19023445号-2号
友情链接