set $auth_header $http_authorization; if ($auth_header != "Bearer API_KEY") { # 替换为你的认证令牌 return 401; # 如果认证失败,返回 401 Unauthorized }