GeoNode / geonode-project

A django template project for creating custom GeoNode projects.
http://geonode.org
78 stars 172 forks source link

Celery is unable to contact geoserver_public_location #210

Open drumbsd opened 3 years ago

drumbsd commented 3 years ago

Problem:

On some specific server configuration, celery is unable to connect to GEOSERVER_PUBLIC_LOCATION.

Details:

If the /etc/hosts on server where the project is built, have the GEOSERVER_PUBLIC_LOCATION configured as 127.0.0.1 like in this specific situation:

127.0.0.1 foo.bar.com 

Celery is unable to connect to foo.bar.com from inside the docker because it resolves the name with 127.0.0.1 that is unavailable inside docker.

Solutions:

We add extra_hosts environment like this:

extra_hosts:
      - "foo.bar.com:$public_ip_address"

With this directive celery is able to connect to the GEOSERVER_PUBLIC_LOCATION

Possible other solutions:

Since , in this case, celery is running inside docker-compose enviroment, maybe it could try to reach geoserver using $GEOSERVER_LOCATION instead of $GEOSERVER_PUBLIC_LOCATION. Using $GEOSERVER_LOCATION celery will resolve the geoserver fqdn using value that is provided by internal docker-compose dns. But I don't know if there's a specific reasons why it needs to connect to geoserver using the $GEOSERVER_PUBLIC_LOCATION, so maybe is not applicable.

frafra commented 2 years ago

This is also problematic in case there is a network firewall with an anti-spoofing mechanism. Communication between GeoNode components should always happen using internal hostnames.