# App Search is redirecting to Localhost

**URL:** <https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822>\
**Category:** Elastic Search\
**Tags:** docker, elastic-app-search\
**Created:** [February 10, 2021, 3:04am UTC](https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822 "2021-02-10T03:04:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![justaniceguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justaniceguy/32/69769_2.png) [@justaniceguy](https://discuss.elastic.co/u/justaniceguy)\
**Post date:** [February 10, 2021, 3:04am UTC](https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822/1 "2021-02-10T03:04:36Z")

</div>

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](http://xxx.xxx.xxx.xxx:3002) (my server IP and the App Search Port) it redirects me to [http://localhost:3002/welcome](http://localhost:3002/welcome)

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

```auto
    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

```

---

<div class="post-metadata">

**Author:** ![orhantoy](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@orhantoy](https://discuss.elastic.co/u/orhantoy)\
**Post date:** [February 10, 2021, 10:09am UTC](https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822/2 "2021-02-10T10:09:32Z")

</div>

👋 @justaniceguy

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

```auto
- 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.

---

<div class="post-metadata">

**Author:** ![justaniceguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justaniceguy/32/69769_2.png) [@justaniceguy](https://discuss.elastic.co/u/justaniceguy)\
**Post date:** [February 10, 2021, 1:06pm UTC](https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822/3 "2021-02-10T13:06:17Z")

</div>

Hi @orhantoy

> [@orhantoy](#):
>
> Are you still being redirected to localhost:3002 when you configure the external URL with
> 
> ```auto
> - app_search.external_url=http://xx.xx.xxx.xxx:3002
> 
> ```
> 
> ?

Yes. I don't know why...

> [@orhantoy](#):
>
> Also, I would recommend that you use Enterprise Search version 7.10.2, which includes App Search.

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![orhantoy](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@orhantoy](https://discuss.elastic.co/u/orhantoy)\
**Post date:** [February 10, 2021, 3:36pm UTC](https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822/4 "2021-02-10T15:36:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![justaniceguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justaniceguy/32/69769_2.png) [@justaniceguy](https://discuss.elastic.co/u/justaniceguy)\
**Post date:** [February 10, 2021, 4:18pm UTC](https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822/5 "2021-02-10T16:18:54Z")

</div>

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

I am trying to add the secret key but [here](https://www.elastic.co/guide/en/enterprise-search/current/encryption-keys.html) it says this value should be an array, so I am trying this:

```auto
      - 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`

---

<div class="post-metadata">

**Author:** ![orhantoy](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@orhantoy](https://discuss.elastic.co/u/orhantoy)\
**Post date:** [February 11, 2021, 3:03pm UTC](https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822/6 "2021-02-11T15:03:08Z")

</div>

I think it should work if you do like this:

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

```

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

---

<div class="post-metadata">

**Author:** ![justaniceguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justaniceguy/32/69769_2.png) [@justaniceguy](https://discuss.elastic.co/u/justaniceguy)\
**Post date:** [February 11, 2021, 3:19pm UTC](https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822/7 "2021-02-11T15:19:50Z")

</div>

> [@orhantoy](#):
>
> I think it should work if you do like this:
> 
> Copy to clipboard
> 
> ```auto
> environment:
> - "secret_management.encryption_keys=[34743777397A24432646294A404E635266556A586E3272
> 
> ```

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

> [@orhantoy](#):
>
> And BTW, please use different encryption keys in production as they are now publicly exposed.

😅 Yeah.. thanks, I almost forgot it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 11, 2021, 3:20pm UTC](https://discuss.elastic.co/t/app-search-is-redirecting-to-localhost/263822/8 "2021-03-11T15:20:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
