0

I want to enable CORS in Geoserver (installed with Tomcat 8). The goal is to access Geoserver maps from Kibana. I made some changes in tomcat/conf/web.xml. But it only works when I install Geoserver + Kibana without Docker. If I use docker-compose, this does not work anymore (Geoserver container crashes):

<filter>
    <filter-name>CorsFilter</filter-name>
    <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
    <init-param>
        <param-name>cors.allowed.origins</param-name>
        <param-value>*</param-value>
    </init-param>
    <init-param>
        <param-name>cors.allowed.headers</param-name>
        <param-value>If-Mofidied-Since,Range,Origin</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>CorsFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

This is my docker-compose related to Geoserver and Kibana:

  geoserver:
    restart: always
    network_mode: "host"
    image: tomcat:8
    volumes:
      - ./geoserver/geoserver/:/usr/local/tomcat/webapps/geoserver
      - ./geoserver/web.xml:/usr/local/tomcat/conf/web.xml
    ports:
      - 8080

  kibana:
    image: docker.elastic.co/kibana/kibana:5.5.0
    network_mode: "host"
    environment:
      ELASTICSEARCH_URL: http://localhost:9200
    volumes:
      - ./kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
    depends_on: ['elasticsearch']

When I open a map in Kibana, I see the message :

Access to XMLHttpRequest at 'http://localhost:8080/geoserver/test/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=test:MyProvinces&outputFormat=application%2Fjson' from origin 'http://localhost:5601' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

  • I am experiencing the exact same problem with the Docker container and CORS. Did you ever solve this issue? – Thibauld Croonenborghs May 3 at 3:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.