dockerelasticsearchdocker-composeelastic-appsearchapp-search

Elastic App Search login fails even after correct credentials


I am unable to login to the Elastic App Search (7.6.0)

I see the Request URL in the header is set to localhost:3002. The request to localhost:3002 would fail on the browser as localhost refers to 127.0.0.1

You can see favicons are trying to load using localhost:3002

enter image description here

Css and JS files load correctly using the domain

enter image description here

The login post request is sent to localhost:3002 port

enter image description here

docker-compose.yml file

version: '3.4'

services:


#Elastic Search Service
elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
    container_name: elasticsearch
    environment:
        - "node.name=es-node"
        - "discovery.type=single-node"
        - "cluster.name=app-search-docker-cluster"
        - "network.host=0.0.0.0"
        - "xpack.security.enabled=true"
        - "action.auto_create_index=.app-search-*-logs-*,-.app-search-*,+*"
        - "bootstrap.memory_lock=true"
        - "ES_JAVA_OPTS=-Xms512m -Xmx1g"
        - "ELASTIC_PASSWORD=${ELASTIC_SEARCH_PASSWORD}"
    volumes:
        - elasticsearch:/usr/share/elasticsearch/data
    ports:
        - 127.0.0.1:9200:9200
        - 127.0.0.1:9300:9300
    networks:
        - internal

#App Search Service
appsearch:
    image: docker.elastic.co/app-search/app-search:7.6.0
    container_name: appsearch
    depends_on:
      - elasticsearch
    environment:
      - "APP_SEARCH_DEFAULT_PASSWORD=${APP_SEARCH_DEFAULT_PASSWORD}"
      - "elasticsearch.password=${ELASTIC_SEARCH_PASSWORD}"
    volumes:
       - ./docker/elastic/appsearch/app-search.yml:/usr/share/app-search/config/app-search.yml
    ports:
      - 127.0.0.1:3002:3002
    networks:
      - internal

volumes:
  elasticsearch:
    driver: local

#Docker Networks
networks:
    internal:
        driver: bridge

app-search.yml

allow_es_settings_modification: true
app_search.listen_host: 0.0.0.0
elasticsearch.host: http://elasticsearch:9200
filebeat_log_directory: /var/log/app-search
log_directory: /var/log/app-search
app_search.auth.source: standard
elasticsearch.username: elastic
elasticsearch.password: ${ELASTIC_SEARCH_PASSWORD}

I want to set or override the localhost:3002 value to "domain-name"

Nginx Reverse Proxy

server {

        server_name <domain-name>;

        location / {
            proxy_pass http://localhost:3002;
        }
}

Solution

  • Adding below as an environment solves the issue:

    app_search.external_url: http://<domain-name>