You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AWS Lambda作为Grafana反向代理遇加载失败问题求助

AWS Lambda作为Grafana反向代理时的静态资源加载故障排查请求

我们尝试使用AWS Lambda作为Grafana的反向代理,采用Node.js编写Lambda代码,具体实现如下:

const express = require('express');
const app = express();
const serverless = require('serverless-http');
const port = 8000;
const varenv = 'production';
app.use(express.static('view'))
var http = require('http');
var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer({});
proxy.on('proxyReq', function (proxyReq, req) {
   proxyReq.setHeader('X-WEBAUTH-USER', 'admin')
});
proxy.on('proxyRes', function (proxyRes, req, res) {
  res.setHeader('Access-Control-Allow-Origin', '*');
});
proxy.on('error', function (err, req, res) {
  res.writeHead(500, {'Content-Type': 'text/plain'});
  res.end("An error occured ....Susanta-101");
});

app.all("/*", function (req, res) {
  console.log("Forwarding to grafana server...")
  proxy.web(req, res, {
     target: 'http://stack-Grafa-1GNU1ALCSQL27-734749157.us-east-1.elb.amazonaws.com/', // link to our target service
     secure: false
  });
})

if (varenv === 'production') {
  console.log("serverless block...!!!")
  exports.handler = serverless(app);
} else {
  app.listen(port,
     () => console.log(`Susanta Listening on port ${port}!`))
}

目前已将该Lambda关联至AWS API Gateway,但通过API URL访问时出现Grafana应用文件加载失败的错误,错误提示附带的可能原因如下:

  • 这可能由反向代理设置导致。
  • 若在子路径下托管Grafana,请确保grafana.ini中的root_url设置包含子路径;若未使用反向代理,请将serve_from_sub_path设为true。
  • 若为本地开发构建,请确保使用yarn start、yarn start:hot或yarn build构建前端。
  • 有时重启grafana-server会有所帮助。
  • 检查是否使用了不支持的浏览器。

恳请协助排查并解决此问题。

谢谢,
Susanta

内容的提问来源于stack exchange,提问作者Susanta Sahu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 12:52:48