1

I have the following set-up:

/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;
    }
}

whenever I do

curl -i -u user:pass http://xxx.xxx.xxx.xxx/

I get 401 Authorization Required

If I remove the auth_basic from nginx conf, everything works smoothly. It's clear to me that the auth bit is problemmatic. Am I doing something wrong?

Erik van de Ven
  • 4,747
  • 6
  • 38
  • 80
Robin Winton
  • 591
  • 10
  • 23
  • yep it was like that when i started. i followed this guide: http://www.minvolai.com/blog/2014/08/Setting-up-a-Secure-Single-Node-Elasticsearch-server-behind-Nginx/Setting-up-a-Secure-Single-Node-Elasticsearch-server-behind-Nginx/ – Robin Winton May 27 '15 at 08:10
  • follow this thread instructions http://stackoverflow.com/questions/2010677/nginx-and-auth-basic – Julien C. May 27 '15 at 08:32

2 Answers2

0

The problem was the way the password was encrypted. when I generated the password, I used bcrypt. more info here.

I've deleted the old pass and creaded a new one with md5(through htpasswd) and works like a charm.

Robin Winton
  • 591
  • 10
  • 23
0

It seems rather probable that the phenomena has to do with your nginx configuration rather than with Elasticsearch. For instance, the password file .htpasswd might not have the appropriate rights or is placed in the wrong folder which is not accessible for nginx.

B--rian
  • 5,578
  • 10
  • 38
  • 89