App Search is redirecting to Localhost

I am trying to install ElasticSearch, Kibana and AppSeach with Docker Compose. I can make ElasticSearch and Kibana work, but App Search redirect to localhost (literaly).

When I visit http://xxx.xxx.xxx.xxx:3002 (my server IP and the App Search Port) it redirects me to http://localhost:3002/welcome

This is the content of my docker-compose-.yml file:

    version: "3.7"
    
    services:
      elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
        container_name: elasticsearch
        restart: always
        environment:
          - xpack.security.enabled=false
          - discovery.type=single-node
          - node.name=es-node-1
          - cluster.name=app-search-docker-cluster
          - bootstrap.memory_lock=true
          - ES_JAVA_OPTS=-Xms512m -Xmx512m
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        cap_add:
          - IPC_LOCK
        volumes:
          - elasticsearch-data-volume:/usr/share/elasticsearch/data
        ports:
          - 9200:9200
    
      appsearch:
        image: docker.elastic.co/app-search/app-search:7.6.2
        environment:
          - elasticsearch.host=http://elasticsearch:9200
          - allow_es_settings_modification=true
          - JAVA_OPTS=-Xms2g -Xmx2g
        ports:
          - 3002:3002
    
      kibana:
        container_name: kibana
        image: docker.elastic.co/kibana/kibana:7.10.2
        restart: always
        environment:
          - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 
          - enterprise_search.host:http://appsearch:3002
        ports:
          - 5601:5601
        depends_on:
          - elasticsearch
    
    
    volumes:
      elasticsearch-data-volume:
        driver: local

EDIT:

I tried to be more specific by adding some variables to appsearch but didn't work:

  - app_search.external_url:http://xx.xx.xxx.xxx:3002
  - app_search.listen_host:xx.xx.xxx.xxx
  - app_search.listen_port:3002

:wave: @justaniceguy

Are you still being redirected to localhost:3002 when you configure the external URL with

- app_search.external_url=http://xx.xx.xxx.xxx:3002

?

Also, I would recommend that you use Enterprise Search version 7.10.2, which includes App Search.
The config is almost the same: app_search.external_url becomes ent_search.external_url, and similarly for the other config options.

Hi @orhantoy

Yes. I don't know why...

I think this is a good idea. I am trying to do it but for some reason docker can't get the service up. It says Starting root_enterprisesearch_1 ... done and if I do a docker container ls right away, it says the service is up but if I do it again after few seconds, then the service is not there any more.

This is my final docker-compse.yml file, maybe I am missing something:

version: "3.7"

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
    container_name: elasticsearch
    restart: always
    environment:
      - xpack.security.enabled=false
      - discovery.type=single-node
      - node.name=es-node-1
      - cluster.name=app-search-docker-cluster
      - bootstrap.memory_lock=true
#      - elasticsearch.username:elastic
#      - elasticsearch.password:changeme
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
      - elasticsearch.host:http://xx.xx.xxx.xxx:9200
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    cap_add:
      - IPC_LOCK
    volumes:
      - elasticsearch-data-volume:/usr/share/elasticsearch/data
    ports:
      - 9200:9200

  enterprisesearch:
    image: docker.elastic.co/enterprise-search/enterprise-search:7.10.2
    environment:
      - elasticsearch.host=http://elasticsearch:9200
      - allow_es_settings_modification=true
      - JAVA_OPTS=-Xms2g -Xmx2g
      - ent_search.auth.source:standard
      - ent_search.external_url:http://xx.xx.xxx.xxx:3002
    ports:
      - 3002:3002

  kibana:
    container_name: kibana
    image: docker.elastic.co/kibana/kibana:7.10.2
    restart: always
    environment:
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200    # address of elasticsearch docker container which kibana will connect
      - enterpriseSearch.host:http://xx.xx.xxx.xxx:3002
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch

volumes:
  elasticsearch-data-volume:
    driver: local

The Enterprise Search logs/output should tell you that you also need to set secret_management.encryption_keys.

Hmm..! I think we are almost there....

I am trying to add the secret key but here it says this value should be an array, so I am trying this:

      - secret_management.encryption_keys:
        - 34743777397A24432646294A404E635266556A586E3272357538782F4125442A
        - 6D5971337436773979244226452948404D635166546A576E5A72347537782141

But I get an error message:

ERROR: The Compose file './elasticsearch-docker-compose.yml' is invalid because:
services.enterprisesearch.environment contains {"secret_management.encryption_keys": ["34743777397A24432646294A404E635266556A586E3272357538782F4125442A", "6D5971337436773979244226452948404D635166546A576E5A72347537782141"]}, which is an invalid type, it should be a string

And if I try just - secret_management.encryption_keys:34743777397A24432646294A404E635266556A586E3272357538782F4125442A (as a string) the service is exited after few seconds.

But now if I do docker ps -a the status show Exited (1) 2 minutes ago

I think it should work if you do like this:

environment:
  - "secret_management.encryption_keys=[34743777397A24432646294A404E635266556A586E3272357538782F4125442A,6D5971337436773979244226452948404D635166546A576E5A72347537782141]"

And BTW, please use different encryption keys in production as they are now publicly exposed.

Thanks! That's the right way to do it.

:sweat_smile: Yeah.. thanks, I almost forgot it.

1 Like