当前位置:论坛首页 > Linux面板 > 建议

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

发表在 Linux面板2026-1-21 21:36 [复制链接] 0 67

[color=var(--devsite-link-color)]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[0]
      -- 判断文件路径中是否合法
      if not ngx.re.find(m[1],"\\./","isjo") then
        -- 判断文件是否存在
        local is_exists = io.open(filename, "r")
        if not is_exists then
            -- Java项目?
            filename = "/www/wwwroot/java_node_ssl" ..  m[0]
        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[1] == "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;
}


使用道具 举报 只看该作者 回复
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表