【问题标题】:How would I secure /netdata, or Netdata for Laravel?我将如何保护 /netdata 或 Laravel 的 Netdata?
【发布时间】:2020-08-12 12:18:41
【问题描述】:

我正在关注the following guide for installing Netdata on Laravel Forge。基本上,它打开了用于 Netdata 的 1999 端口并将其重定向到 /netdata 目录。

location = /netdata {
  return 301 /netdata/;
}

location ~ /netdata/(?<ndpath>.*) {
  proxy_redirect off;
  proxy_set_header Host $host;

  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_http_version 1.1;
  proxy_pass_request_headers on;
  proxy_set_header Connection "keep-alive";
  proxy_store off;
  proxy_pass http://netdata/$ndpath$is_args$args;

  gzip on;
  gzip_proxied any;
  gzip_types *;
}
upstream netdata {
  server 127.0.0.1:19999;
  keepalive 64;
}

我已经定义了一个auth 中间件,我如何只允许通过auth 中间件的人访问/netdata 路由?该指南建议仅将其限制为一个 IP 地址,但这是不可能的,因为我四处走动。

【问题讨论】:

    标签: php laravel networking netdata


    【解决方案1】:

    虽然我没有使用 Laravel 或 Forge 的经验,但根据 documentation 的这篇文章,您必须在中间件中定义该功能。本质上,您指示中间件仅在身份验证成功的情况下执行重定向。

    也许你可以指示 Laravel 将所有连接(如果 auth 成功)重定向到 NGINX 端点(/netdata),你将其配置为只允许来自localhost。因此,用户将无法访问/netdata,除非他/她通过 Laravel 中间件进行身份验证,然后从该中间件重定向到 Nginx 服务器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-07
      相关资源
      最近更新 更多