加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

使用Nginx作为代理来防止通过JavaScript客户端在ElasticSearch上

发布时间:2020-12-13 21:36:48 所属栏目:Nginx 来源:网络整理
导读:我有一个本地ElasticSearch服务器,由Nginx公开,可以防止POST,PUT和DELETE请求.这是我的Nginx配置足以防止信息获取之外的操作?你建议改进吗? upstream elasticsearch { server localhost:9200; } server { listen 7777; location / { return 403; limit_exc

我有一个本地ElasticSearch服务器,由Nginx公开,可以防止POST,PUT和DELETE请求.这是我的Nginx配置足以防止信息获取之外的操作?你建议改进吗?

  upstream elasticsearch {
      server localhost:9200;
  }

  server {
      listen 7777;

      location / {
        return 403;
        limit_except PUT POST DELETE {
          proxy_pass http://elasticsearch;
        }
        proxy_redirect off;
      }

  }

谢谢.

[UPDATE]

我的配置在deagh的建议之后:

  upstream elasticsearch {
      server localhost:9200;
  }

  server {
      listen 7777;

      location / {
        return 403;
        limit_except PUT POST DELETE {
          proxy_pass http://elasticsearch;
        }
        proxy_redirect off;
      }

      location ~* ^(/_cluster|/_nodes|/_shutdown) {
        return 403;
        break;
      }

  }
最佳答案
您还应该注意与不同弹性体位置的连接

> _cluster
> _nodes
> _shutdown

您可以在documentation =>中找到有关nginx和elasticsearch的工作(和安全)设置的更多信息. http://www.elasticsearch.org/blog/playing-http-tricks-nginx/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读