Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save abrudtkuhl/cfddc0e80af401120136 to your computer and use it in GitHub Desktop.
Save abrudtkuhl/cfddc0e80af401120136 to your computer and use it in GitHub Desktop.

Revisions

  1. abrudtkuhl revised this gist Jul 11, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions nginx-elasticsearch-proxy.conf
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    #
    # All requests are then routed to authenticated user's index, so
    #
    # GET http://user:password@localhost:8080/_search?q=*
    # GET http://user:password@localhost/_search?q=*
    #
    # is rewritten to:
    #
    @@ -23,7 +23,7 @@ http {

    server {

    listen 8080;
    listen 80;
    server_name search.example.com;

    error_log elasticsearch-errors.log;
  2. abrudtkuhl revised this gist Jul 11, 2014. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions nginx-elasticsearch-proxy.conf
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    #
    # is rewritten to:
    #
    # GET http://localhost:9200/user/_search?q=*
    # GET http://localhost:9200/_search?q=*

    worker_processes 1;

    @@ -49,13 +49,12 @@ http {
    auth_basic "ElasticSearch";
    auth_basic_user_file passwords;

    # Route all requests to authorized user's own index
    rewrite ^(.*)$ /$remote_user$1 break;
    # Route all requests to the root index
    rewrite ^(.*)$ $1 break;
    rewrite_log on;

    return 403;

    }

    }
    }
  3. @karmi karmi revised this gist Jan 24, 2012. No changes.
  4. @karmi karmi revised this gist May 23, 2011. No changes.
  5. @karmi karmi revised this gist May 23, 2011. No changes.
  6. @karmi karmi revised this gist May 23, 2011. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions nginx-elasticsearch-proxy.conf
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,13 @@
    #
    # $ nginx -p /path/to/this/file/ -c nginx.conf
    #
    # All requests are then routed to authenticated user's index, so
    #
    # GET http://user:password@localhost:8080/_search?q=*
    #
    # is rewritten to:
    #
    # GET http://localhost:9200/user/_search?q=*

    worker_processes 1;

  7. @karmi karmi created this gist May 23, 2011.
    54 changes: 54 additions & 0 deletions nginx-elasticsearch-proxy.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    # Run me with:
    #
    # $ nginx -p /path/to/this/file/ -c nginx.conf
    #

    worker_processes 1;

    pid nginx.pid;

    events {
    worker_connections 1024;
    }


    http {

    server {

    listen 8080;
    server_name search.example.com;

    error_log elasticsearch-errors.log;
    access_log elasticsearch.log;

    location / {

    # Deny access to Cluster API
    if ($request_filename ~ "_cluster") {
    return 403;
    break;
    }

    # Pass requests to ElasticSearch
    proxy_pass http://localhost:9200;
    proxy_redirect off;

    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;

    # Authorize access
    auth_basic "ElasticSearch";
    auth_basic_user_file passwords;

    # Route all requests to authorized user's own index
    rewrite ^(.*)$ /$remote_user$1 break;
    rewrite_log on;

    return 403;

    }

    }
    }