Elasticsearch and Nginx Configuration not Working in AWS production server

Hi,

I got a fresh copy of Zammad 3.2 from the GitHub repository.
And I just setup Zammad on an AWS Ubuntu 18.04 production server.
I have installed Ruby on Rails , Elasticsearch , PostgreSQL and other dependencies on the server.

I am trying to to configure Nginx and Elasticsearch, since when I try search for anything on Zammad I get the Elasticsearch need to be configured screen.

I have opened the 9200 port on the AWS server for Elasticsearch.

Here is the Elasticsearch network settings configuration (elasticsearch.yml)

# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200

I have created the auth file in /etc/nginx/.htpasswd-elasticsearch with my preferred username and password.

I have also created the Nginx config file for Elasticsearch.
Here is the Nginx configuration for Elasticsearch

upstream elasticsearch {
    server 127.0.0.1:9200;
}

server {
    listen 9200;

    auth_basic "Elasticsearch";
    auth_basic_user_file /etc/nginx/.htpasswd-elasticsearch;

    location / {
        proxy_pass http://elasticsearch;
    }
}

But when I try to restart the Nginx server it gives me the error

error.......bind() to 0.0.0.0:9200 failed (98: Address already in use)

Infos:

  • Used Zammad version: Zammad v3.2.0
  • Used Zammad installation source: git repository source
  • Operating system: Ubuntu 18.04
  • Browser + version: Google Chrome v77
  • Elasticsearch: Elasticsearch 7.x

Expected behavior:

  • I expect all the search functionality of Zammad to work

Actual behavior:

  • Zammad displays the screen Elasticsearch need to be configured

Steps to reproduce the behavior:

  • Setup a new AWS server
  • Install Ruby on Rails, Elasticsearch, Nginx on the server
  • Clone a copy of Zammad from GitHub to the server.

No offense, but please use the official documentations, I have no clue why you want to proxy elasticsearch through your nginx, but it’s not needed in any way.

Here’s the source code installation:
https://docs.zammad.org/en/latest/install-source.html#

and here you can find what to do with elasticsearch:
https://docs.zammad.org/en/latest/install-elasticsearch.html

Elasticsearch configuration is done via Settings via rails console, not via nginx (your webserver!).
Please be careful, because you don’t want to make your elasticsearch public without any authentication and stuff.

1 Like

Thank you so much for the clarification.

When I try to configure Zammad to work with Elasticsearch by running the command below

rails r "Setting.set('es_url', 'http://localhost:9200')"

I get the error

FATAL: database “zammad_development” does not exist (ActiveRecord::NoDatabaseError)

My production database name is zammad_production.

What command do I run to make Elasticsearch to find the zammad_production and not zammad_development?

Do I need to replace localhost with the IP address of my AWS virtual machine?

I have been able to fix it.

I deleted the Nginx configuration for Elasticsearch

I then ran the command below, and it worked

RAILS_ENV=production rails r "Setting.set('es_url', 'http://localhost:9200')"

The issue I had was that I was not specifying the Rails Environment, so once I specified RAILS_ENV=production in my command, it worked.

Thank you so much.

1 Like

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