CORS problem in Kibana Map

Hi,
I run ELK on liunx (CetnOS7) server in intranet environment.
Because of intranet environment, all original Map in Kibana not work.
So I want to use custom map in Kibana.
I download map geojson file form https://exploratory.io/map

I set this in kibana.yml:

#Custom Region Maps
map.regionmap:
  includeElasticMapsService: false
  layers:
     - name: "World Map"
       url: "http://localhost:8080/world.geojson"
       attribution: "https://exploratory.io/map"
       fields:
          - name: "WORLD"
            description: "world map"

server.cors : true
server.cors.origin: "*"

The url is working because when I type in browser, it will download a file world.geojson

And set this in elasticsearch.yml

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: X-Requested-With, X-Auth-Token, Content-Type, Content-Length, kbn-version, Origin, Content-Type, Accept, Engaged-Auth-Token

But when I open Maps in Kibana, it shows blank background.
And when I open region map in Kibana-Visualize, it also shows blank background with:

Error downloading vector data
Cannot download  World Map file. Please ensure the CORS configuration of the server permits requests from the Kibana application on this host

How could I fix it?
Thank you!

It looks like you may have specified the fields incorrectly in your kibana.yml. There is no WORLD attribute in the exploratory.io World Map GeoJSON file. The fields definition refers to the attributes in the GeoJSON file.

Hi nickpeohl,
I found official documents about:

fields:
Mandatory. Each layer can contain multiple fields to indicate what properties from the geojson features you wish to expose. The example above shows how to define multiple properties.

fields.name:
Mandatory. This value is used to do an inner-join between the document stored in Elasticsearch and the geojson file. e.g. if the field in the geojson is called Location and has city names, there must be a field in Elasticsearch that holds the same values that Kibana can then use to lookup for the geoshape data.

fields.description:
Mandatory. The human readable text that is shown under the Options tab when building the Region Map visualization

In tutorial example from Custom Region Maps in Kibana 6.0 | Elastic Blog

It's setting in kibana.yml is:

# Custom Region Maps
regionmap:
  layers:
     - name: "Australian States"
       url: "http://localhost:8000/aus_state.geojson"
       attribution: "https://exploratory.io/maps"
       fields:
          - name: "STATE_NAME"
            description: "State Name"

And it's aus_state.geojson file has fields like this:

"properties": {
        "STATE_CODE": "1",
        "STATE_NAME": "New South Wales",
        "rmapshaperid": 0
      },
"id": 0

So I change my setting in kibana.yml:

#Custom Region Maps
map.regionmap:
  includeElasticMapsService: false
  layers:
     - name: "World Map"
       url: "http://localhost:8080/world.geojson"
       attribution: "https://exploratory.io/map"
       fields:
          - name: "NAME"
            description: "country name"

Where my world.geojson file has fields like this

 "properties": {
        "NAME": "Afghanistan",
        "NAME_LONG": "Afghanistan",
        "ADM0_A3": "AFG",
        "ISO_A2": "AF",
        "ISO_A3": "AFG",
        "WB_A2": "AF",
        "WB_A3": "AFG"
      },
 "id": 1

But it still shows same CORS error message.
Where is the problem?
Thank you!

What are you using to host the local GeoJSON file?

In the blog post we give an example of using http-server --cors='*' -p 8000. But I've found that http-server --cors="kbn-version" -p 8000 works better.

Hi nickpeihl,
Because of intranet environment, It' unable to install http-server by using npm install http-server -g like what they do in tutorial .

And I can't find any other way to install http-server, so I use Wildfly to host the local GeoJSON file.

At a minimum you should make sure CORS is enabled in your Wildfly server and that it accepts the kbn-version header. Unfortunately, I'm not familiar with Wildfly so I do not know how this CORS is configured.

Hi nickpeihl,
Thanks for your advice about make sure CORS is enabled and accepts the kbn-version header.

I will study for it.
Thank You!!! :grinning:
Daniel.

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