0

Having this docker compose (v2) file for setting up a local (Ubuntu) QGIS server:

services:
  qgis:
    image: "camptocamp/qgis-server:latest"
    environment:
      PGSERVICEFILE: "/etc/qgisserver/pg_service.conf"
      QGIS_PROJECT_FILE: "/etc/qgisserver/foo/foos.qgs"
      QGIS_SERVER_LOG_LEVEL: 0
    volumes:
     - ./data:/etc/qgisserver
    ports:
      - "8080:80" 

a valid QGIS server project file ./data/foo/foo.qgs connecting to two samples layers in a local PostGIS database and this ./data/pg_service.conf file:

[test]
  host=host.ip.address
  port=5432
  dbname=foo
  user=postgres
  password=****************

I'm facing this QGIS server error:

test-qgis-1  | 09:10:21 WARNING PostGIS[70]: Connection to database failed
test-qgis-1  | service file "/etc/qgisserver/pg_service.conf" not found

I don't know why, because the $PGSERVICEFILE variable is correctly set up and when I log into the container, I can successfully connect to the database using this pg service and the command: psql -d service=test.

Full request log:

test-qgis-1  | 09:10:21 INFO Server[70]: ******************** New request ***************
test-qgis-1  | 09:10:21 INFO Server[70]: Request URL: http://localhost:8080/qgis/wfs3
test-qgis-1  | 09:10:21 INFO Server[70]: Environment:
test-qgis-1  | 09:10:21 INFO Server[70]: ------------------------------------------------
test-qgis-1  | 09:10:21 INFO Server[70]: SERVER_NAME: localhost
test-qgis-1  | 09:10:21 INFO Server[70]: REQUEST_URI: /qgis/wfs3
test-qgis-1  | 09:10:21 INFO Server[70]: SCRIPT_NAME: /qgis/wfs3
test-qgis-1  | 09:10:21 INFO Server[70]: REMOTE_ADDR: 172.27.0.1
test-qgis-1  | 09:10:21 INFO Server[70]: SERVER_PORT: 8080
test-qgis-1  | 09:10:21 INFO Server[70]: QUERY_STRING: 
test-qgis-1  | 09:10:21 INFO Server[70]: REQUEST_METHOD: GET
test-qgis-1  | 09:10:21 INFO Server[70]: QGIS_PROJECT_FILE: /etc/qgisserver/foo/foo.qgs
test-qgis-1  | 09:10:21 INFO Server[70]: SERVER_PROTOCOL: HTTP/1.1
test-qgis-1  | Headers:
test-qgis-1  | ------------------------------------------------
test-qgis-1  | "Accept" :  "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
test-qgis-1  | "Host" :  "localhost:8080"
test-qgis-1  | "User-Agent" :  "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0"
test-qgis-1  | 09:10:21 WARNING PostGIS[70]: Connection to database failed
test-qgis-1  | service file "/etc/qgisserver/pg_service.conf" not found
test-qgis-1  | 
test-qgis-1  | 09:10:21 WARNING PostGIS[70]: Connection to database failed
test-qgis-1  | service file "/etc/qgisserver/pg_service.conf" not found
test-qgis-1  | 
test-qgis-1  | 09:10:21 CRITICAL Server[70]: Error, Layer(s) firstlayer_bfca477a_6cfb_4009_9f7a_e07afa052d65, secondlayer_809e7822_0380_4bbf_bd4b_68c94b210dc3 not valid in project /etc/qgisserver/foo/foo.qgs
test-qgis-1  | 09:10:21 WARNING Server[70]: <?xml version="1.0" encoding="UTF-8"?>
test-qgis-1  | <ServerException>Layer(s) not valid</ServerException>
test-qgis-1  | 
test-qgis-1  | 09:10:21 INFO Server[70]: Request finished in 11 ms
test-qgis-1  | 853630 - 172.27.0.1 - - [28/Nov/2023:09:10:20 +0000] "GET /qgis/wfs3 HTTP/1.1" 500 310 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0"

Rights on the pg_service.conf file on the host and inside the container are as follow:

root@qgis-container:/etc/qgisserver# ls -lh pg_service.conf 
-rw------- 1 1000 1000 92 Nov 27 22:34 pg_service.conf

(Database version on the host is PostgreSQL 15.5 (Ubuntu 15.5-1.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit with PostGIS 3.4)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.