宝塔用户_afpmbc 发表于 2026-1-21 21:36:19

/.well-known/assetlinks.json不能通过验证,被SSL证书配置拦截

App Linking验证地址:https://developers.google.com/digital-asset-links/tools/generator

网站下的 /.well-known/assetlinks.json 这个文件死活都验证不能过,在主配置文件里这么写,
location = /.well-known/assetlinks.json {
      allow all;
      root /www/wwwroot/www.xxx.com;
      default_type application/json;
      add_header Content-Type application/json;
      add_header Cache-Control "no-cache, no-store, must-revalidate";
      add_header Pragma "no-cache";
      add_header Expires 0;
      try_files $uri =404;
    }

最后面发现是这个文件/www/server/panel/vhost/nginx/well-known/xxxx.conf写死了ngx.header['content-type'] = 'text/plain'
一开始又不敢动这个文件,怕以后升级什么的,会被覆盖了,到时就出问题,折腾很久,也上网搜索了一通,AI问了一通,最后只有动这个文件了,唉

set $well_known '';
if ( $uri ~ "^/.well-known/" ) {
set_by_lua_block $well_known {
    -- 获取路径
    local m,err = ngx.re.match(ngx.var.uri,"/.well-known/(.*)","isjo")
    -- 如果路径匹配
    if m then
      -- 拼接文件路径
      local filename = ngx.var.document_root .. m
      -- 判断文件路径中是否合法
      if not ngx.re.find(m,"\\./","isjo") then
      -- 判断文件是否存在
      local is_exists = io.open(filename, "r")
      if not is_exists then
            -- Java项目?
            filename = "/www/wwwroot/java_node_ssl" ..m
      end
      -- 释放
      if is_exists then is_exists:close() end
      -- 读取文件
      local fp = io.open(filename,'r')
      if fp then
          local file_body = fp:read("*a")
          fp:close()
          if file_body then

            if m == "assetlinks.json" then
            ngx.header['content-type'] = 'application/json'
            else
            ngx.header['content-type'] = 'text/plain'
            end

            return file_body
          end
      end
      end
    end
    return ""
}
}

if ( $well_known != "" ) {
return 200 $well_known;
}


页: [1]
查看完整版本: /.well-known/assetlinks.json不能通过验证,被SSL证书配置拦截