【问题标题】:Elasticsearch basic auth with nginx使用 nginx 进行 Elasticsearch 基本身份验证
【发布时间】:2015-05-26 16:57:06
【问题描述】:

我有以下设置:

/etc/nginx/sites-available/elasticsearch

server {
    listen 80;
    server_name xxx.xxx.xxx.xxx;
    auth_basic "Elasticsearch Authentication";
    auth_basic_user_file /etc/elasticsearch/es.pwd;

    location / {
        rewrite ^/(.*) /$1 break;
        proxy_ignore_client_abort on;
        proxy_pass http://localhost:9200;
        proxy_redirect http://localhost:9200 http://xxx.xxx.xxx.xxx/;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
    }
}

无论何时

curl -i -u 用户:通过http://xxx.xxx.xxx.xxx/

我得到 401 需要授权

如果我从 nginx conf 中删除 auth_basic,一切都会顺利进行。 我很清楚 auth 位是有问题的。我做错了吗?

【问题讨论】:

标签: nginx elasticsearch


【解决方案1】:

问题在于密码的加密方式。当我生成密码时,我使用了 bcrypt。更多信息here.

我已经删除了旧的通行证并使用 md5(通过 htpasswd)创建了一个新通行证,并且工作起来就像一个魅力。

【讨论】:

    【解决方案2】:

    这种现象似乎很可能与您的 nginx 配置有关,而不是与 Elasticsearch 有关。例如,密码文件.htpasswd 可能没有适当的权限,或者放置在 nginx 无法访问的错误文件夹中。

    【讨论】:

      猜你喜欢
      • 2015-08-12
      • 2017-06-13
      • 2013-05-30
      • 1970-01-01
      • 2016-05-31
      • 2017-10-06
      • 2013-09-14
      • 2010-12-11
      • 2016-08-24
      相关资源
      最近更新 更多