zerebubuth/openstreetmap-cgimap

Lighthttpd FastCGI unable to start due to permission denied

Closed this issue · 12 comments

When I execute the docker-compose file, all services mentioned in it work properly except for the lighttpd service, which encounters an issue (permission denied). When I run docker compose file, I am getting this

 ✔ Container troubleshoot-lighttpd-1  Created                                                                                                                          0.0s
Attaching to troubleshoot-lighttpd-1
troubleshoot-lighttpd-1  | Starting lighttpd server...
troubleshoot-lighttpd-1  | 2024-04-17 20:51:39: (server.c.1568) server started (lighttpd/1.4.64)
troubleshoot-lighttpd-1  | 2024-04-17 20:51:39: (gw_backend.c.1619) invalid "bin-path" => "/openstreetmap-cgimap" (check that file exists, is regular file, and is executable by lighttpd)
troubleshoot-lighttpd-1  | 2024-04-17 20:51:39: (gw_backend.c.530) connect /tmp/map-fastcgi.socket-0: Connection refused
troubleshoot-lighttpd-1  | /openstreetmap-cgimap: Permission denied
troubleshoot-lighttpd-1  | 2024-04-17 20:51:39: (gw_backend.c.373) child exited: 13 unix:/tmp/map-fastcgi.socket-0
troubleshoot-lighttpd-1  | 2024-04-17 20:51:39: (gw_backend.c.656) gw-backend failed to start: /openstreetmap-cgimap
troubleshoot-lighttpd-1  | 2024-04-17 20:51:39: (gw_backend.c.658) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version.  If this is PHP on Gentoo, add 'fastcgi' to the USE flags.  If this is PHP, try removing the bytecode caches for now and try again.
troubleshoot-lighttpd-1  | 2024-04-17 20:51:39: (gw_backend.c.1700) [ERROR]: spawning gw failed.
troubleshoot-lighttpd-1  | 2024-04-17 20:51:39: (server.c.1572) Configuration of plugins failed. Going down.
troubleshoot-lighttpd-1 exited with code 255

I am sharing the docker compose snippet for lighttpd

version: "3.2"

services:
  lighttpd:
    image: sebp/lighttpd:latest
    volumes:
      - type: bind
        source: ./docker/lighttpd/config
        target: /etc/lighttpd
    ports:
      - "31500:31337"
    command:
      - start.sh
    depends_on:
      - cgimap
      - web

any suggestion to resolve this issue?

There have been many changes to the project structure recently, and the Docker documentation doesn't fully reflect these changes yet. By looking at the error message above, it seems you still to build the "cgimap" docker image first (it is referenced in the "depends_on" section of your docker-compose.yml file).

You are using the config option "bin-path" => "/openstreetmap-cgimap" for your lighttpd server container, which will cause it to try and start a /openstreetmap-cgimap binary inside the lighttpd docker container. You need to run a separate container with openstreetmap-cgimap listening on a socket and configure lighttpd to connect to that socket instead of trying to start openstreetmap-cgimap by itself.

See the lighttpd configuration example snippets at the bottom here: #213 (comment)

I modified it according to your suggestion and permission denied problem is resolved but getting this

docker compose up
[+] Running 5/5
 ⠿ Network openstreetmap-cgimap_default       Created                                                                                                                  0.3s
 ⠿ Container openstreetmap-cgimap-db-1        Created                                                                                                                  0.3s
 ⠿ Container openstreetmap-cgimap-web-1       Created                                                                                                                  0.4s
 ⠿ Container openstreetmap-cgimap-cgimap-1    Created                                                                                                                  0.4s
 ⠿ Container openstreetmap-cgimap-lighttpd-1  Created                                                                                                                  0.6s
Attaching to openstreetmap-cgimap-cgimap-1, openstreetmap-cgimap-db-1, openstreetmap-cgimap-lighttpd-1, openstreetmap-cgimap-web-1
openstreetmap-cgimap-db-1        | /sbin/entrypoint.sh: line 5: /etc/docker-postgresql/functions: No such file or directory
openstreetmap-cgimap-db-1 exited with code 1
openstreetmap-cgimap-web-1       | /usr/local/bin/openstreetmap-cgimap: error while loading shared libraries: libbrotlienc.so.1: cannot open shared object file: No such file or directory
openstreetmap-cgimap-cgimap-1    | /usr/local/bin/openstreetmap-cgimap: error while loading shared libraries: libbrotlienc.so.1: cannot open shared object file: No such file or directory
openstreetmap-cgimap-web-1 exited with code 127
openstreetmap-cgimap-cgimap-1 exited with code 127
openstreetmap-cgimap-lighttpd-1  | chmod: /dev/pts/0: No such file or directory
openstreetmap-cgimap-lighttpd-1  | 2024-04-19 18:33:27: (server.c.1568) server started (lighttpd/1.4.64)
openstreetmap-cgimap-lighttpd-1  | 2024-04-19 18:33:27: (sock_addr.c.454) getaddrinfo failed: Try again 'cgimap'
openstreetmap-cgimap-lighttpd-1  | 2024-04-19 18:33:2

Ah, that's a bug really. I forgot to add Brotli libraries in the second stage in the Docker files. For the time being, I'd suggest to use version 0.9.0 instead to build the cgimap Docker image (git checkout v0.9.0), until we have fixed this.

https://github.com/zerebubuth/openstreetmap-cgimap/blob/master/docker/debian/Dockerfile_bookworm#L34

I'm not sure where this line is coming from:

/sbin/entrypoint.sh: line 5: /etc/docker-postgresql/functions: No such file or directory

Also in docker-compose.yml file

db:
    build:
      context: .
      dockerfile: docker/postgres/Dockerfile
    ports:
      - "54321:5432"
    environment:
      POSTGRES_DB: openstreetmap
    volumes:
      - ./docker-db-data:/var/lib/postgresql/data 

here "dockerfile: docker/postgres/Dockerfile" -- I do not see any postgres folder in dockerfile. Could you please check?

docker/postgres/Dockerfile is coming from the openstreetmap-website project: https://github.com/openstreetmap/openstreetmap-website/blob/master/docker/postgres/Dockerfile

You need to use the docker-compose file in #213 along with the openstreetmap-website Rails project. It is meant to complement the Docker instructions for Rails, so that you could run some of the API endpoints via CGImap instead.

Maybe you better start with that Rails project first, and then try to add CGImap in a second step. This also depends a bit on what exactly you're trying to achieve.

docker/postgres/Dockerfile is coming from the openstreetmap-website project: https://github.com/openstreetmap/openstreetmap-website/blob/master/docker/postgres/Dockerfile

You need to use the docker-compose file in #213 along with the openstreetmap-website Rails project. It is meant to complement the Docker instructions for Rails, so that you could run some of the API endpoints via CGImap instead.

Maybe you better start with that Rails project first, and then try to add CGImap in a second step. This also depends a bit on what exactly you're trying to achieve.

Yes, I have already hosted the OpenStreetMap (OSM) planet using the OSM-website repository, and it's running. However, API calls are slow. My current goal is to adopt the OSM-cgimap model to speed up query calls. So far, I have modified it according to suggestions. Current OSM-cgimap process gives this -- "

[+]
 Running 5/5
 ⠿ Network openstreetmap-test_default       Created                                                                                                                    0.5s
 ⠿ Container openstreetmap-test-db-1        Created                                                                                                                    0.5s
 ⠿ Container openstreetmap-test-cgimap-1    Created                                                                                                                    0.6s
 ⠿ Container openstreetmap-test-web-1       Created                                                                                                                    0.6s
 ⠿ Container openstreetmap-test-lighttpd-1  Created                                                                                                                    0.3s
Attaching to openstreetmap-test-cgimap-1, openstreetmap-test-db-1, openstreetmap-test-lighttpd-1, openstreetmap-test-web-1
openstreetmap-test-db-1        |
openstreetmap-test-db-1        | PostgreSQL Database directory appears to contain a database; Skipping initialization
openstreetmap-test-db-1        |
openstreetmap-test-db-1        | 2024-04-19 20:36:42.283 UTC [1] LOG:  starting PostgreSQL 14.11 (Debian 14.11-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
openstreetmap-test-db-1        | 2024-04-19 20:36:42.284 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
openstreetmap-test-db-1        | 2024-04-19 20:36:42.284 UTC [1] LOG:  listening on IPv6 address "::", port 5432
openstreetmap-test-db-1        | 2024-04-19 20:36:42.301 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
openstreetmap-test-db-1        | 2024-04-19 20:36:42.770 UTC [27] LOG:  database system was shut down at 2024-04-19 20:32:49 UTC
openstreetmap-test-db-1        | 2024-04-19 20:36:42.801 UTC [1] LOG:  database system is ready to accept connections
openstreetmap-test-web-1       | /usr/local/bin/openstreetmap-cgimap: error while loading shared libraries: libbrotlienc.so.1: cannot open shared object file: No such file or directory
openstreetmap-test-cgimap-1    | /usr/local/bin/openstreetmap-cgimap: error while loading shared libraries: libbrotlienc.so.1: cannot open shared object file: No such file or directory
openstreetmap-test-web-1 exited with code 127
openstreetmap-test-cgimap-1 exited with code 127
openstreetmap-test-lighttpd-1  | chmod: /dev/pts/0: No such file or directory
openstreetmap-test-lighttpd-1  | 2024-04-19 20:36:44: (server.c.1568) server started (lighttpd/1.4.64)
openstreetmap-test-lighttpd-1  | 2024-04-19 20:36:44: (sock_addr.c.454) getaddrinfo failed: Try again 'cgimap'
openstreetmap-test-lighttpd-1  | 2024-04-19 20:36:44: (server.c.1572) Configuration of plugins failed. Going down.
openstreetmap-test-lighttpd-1 exited with code 255

error while loading shared libraries: libbrotlienc.so.1: cannot open shared object file: No such file or directory

Like I mentioned in #394 (comment), you would need to either switch to version 0.9.0, or use the latest master (I have fixed this issue about an hour ago).

Both require you to rebuild the cgimap Docker image.

Edit: I have added some automated tests to Github Actions now, to detect similar issues early on.

So far, I am using the updated repo. It looks like containers are running, though I'm getting a connection refused error. When hitting port 31500 through the browser, I'm receiving a '503 Service Unavailable' error. Similarly, when I hit port 3000, I'm seeing a 'refused to connect' error. Here is the outputs after running the containers

openstreetmap-cgimap-db-1        | 2024-04-28 05:17:24.756 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
openstreetmap-cgimap-db-1        | 2024-04-28 05:17:24.756 UTC [1] LOG:  listening on IPv6 address "::", port 5432
openstreetmap-cgimap-db-1        | 2024-04-28 05:17:24.757 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
openstreetmap-cgimap-db-1        | 2024-04-28 05:17:24.760 UTC [67] LOG:  database system was shut down at 2024-04-28 05:17:24 UTC
openstreetmap-cgimap-db-1        | 2024-04-28 05:17:24.765 UTC [1] LOG:  database system is ready to accept connections
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #11] Initialised
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #13] Initialised
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #16] Initialised
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #12] Initialised
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #15] Initialised
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #17] Initialised
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #18] Initialised
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #21] Initialised
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #20] Initialised
openstreetmap-cgimap-web-1       | [2024-04-28T05:17:25 #19] Initialised
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #10] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #11] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #14] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #13] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #15] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #16] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #17] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #18] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #19] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #20] connection to server at "db" (172.31.0.2), port 5432 failed: Connection refused
openstreetmap-cgimap-cgimap-1    |      Is the server running on that host and accepting TCP/IP connections?
openstreetmap-cgimap-cgimap-1    |
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #21] Initialised
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #23] Initialised
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #22] Initialised
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #25] Initialised
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #24] Initialised
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #26] Initialised
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #27] Initialised
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #28] Initialised
openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #29] Initialised
**openstreetmap-cgimap-cgimap-1    | [2024-04-28T05:17:25 #30] Initialised
openstreetmap-cgimap-lighttpd-1  | chmod: /dev/pts/0: No such file or directory
openstreetmap-cgimap-lighttpd-1  | 2024-04-28 05:17:25: (server.c.1568) server started (lighttpd/1.4.64)
openstreetmap-cgimap-lighttpd-1  | 2024-04-28 05:20:00: (gw_backend.c.285) establishing connection failed: socket: tcp:172.31.0.4:3000: Connection refused
openstreetmap-cgimap-lighttpd-1  | 2024-04-28 05:20:00: (gw_backend.c.995) all handlers for /? on  are down.
openstreetmap-cgimap-lighttpd-1  | 2024-04-28 05:20:03: (gw_backend.c.362) gw-server re-enabled: tcp:172.31.0.4:3000 172.31.0.4 3000**

Could you please suggest me possible solutions of these errors? Thanks!

Did you manage to follow the steps in https://github.com/openstreetmap/openstreetmap-website/blob/master/DOCKER.md without issues? If not, please try this first before continuing with CGImap.

Also, can you post your full docker-compose.yml, please? Maybe you upload it here: https://gist.github.com/

As a reference, I'm posting the respective files here, which are working on my local machine:

(following the changes described in #213 (comment) towards the end)

Did you manage to follow the steps in https://github.com/openstreetmap/openstreetmap-website/blob/master/DOCKER.md without issues? If not, please try this first before continuing with CGImap.

Also, can you post your full docker-compose.yml, please? Maybe you upload it here: https://gist.github.com/

As a reference, I'm posting the respective files here, which are working on my local machine:

(following the changes described in #213 (comment) towards the end)

Yes. I completed all the steps ( https://github.com/openstreetmap/openstreetmap-website/blob/master/DOCKER.md) without any issues. Here I have attached links of docker-compose.yml and lighttpd.config:
docker-compose.ym --->https://gist.github.com/reshadshuvo123/84112ee6f09fb36ae38103ee336d4f5a lighttpd --> https://gist.github.com/reshadshuvo123/0a690d5e90cadb9eed072bb3a9ee3e38

Thanks! I don't see any obvious difference at the moment. When I run docker compose up, I'm getting the following output. By the way, I'm running docker compose in the openstreetmap-website directory, and have modified the docker-compose.yml in there. Also, I have created a new file in there as docker/lighttpd/config/lighttpd.conf .

 ✔ Container openstreetmap-website-db-1        Created                                                                                                                                0.0s 
 ✔ Container openstreetmap-website-cgimap-1    Created                                                                                                                                0.0s 
 ✔ Container openstreetmap-website-web-1       Created                                                                                                                                0.0s 
 ✔ Container openstreetmap-website-lighttpd-1  Created                                                                                                                                0.0s 
Attaching to cgimap-1, db-1, lighttpd-1, web-1
db-1        | 
db-1        | PostgreSQL Database directory appears to contain a database; Skipping initialization
db-1        | 
db-1        | 2024-04-29 18:36:00.347 UTC [1] LOG:  starting PostgreSQL 14.11 (Debian 14.11-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
db-1        | 2024-04-29 18:36:00.347 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db-1        | 2024-04-29 18:36:00.347 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db-1        | 2024-04-29 18:36:00.351 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db-1        | 2024-04-29 18:36:00.358 UTC [27] LOG:  database system was shut down at 2024-04-29 18:35:56 UTC
db-1        | 2024-04-29 18:36:00.363 UTC [1] LOG:  database system is ready to accept connections
cgimap-1    | [2024-04-29T18:36:00 #11] Initialised
cgimap-1    | [2024-04-29T18:36:00 #9] Initialised
cgimap-1    | [2024-04-29T18:36:00 #10] Initialised
cgimap-1    | [2024-04-29T18:36:00 #14] Initialised
cgimap-1    | [2024-04-29T18:36:00 #12] Initialised
cgimap-1    | [2024-04-29T18:36:00 #15] Initialised
cgimap-1    | [2024-04-29T18:36:00 #19] Initialised
cgimap-1    | [2024-04-29T18:36:00 #17] Initialised
cgimap-1    | [2024-04-29T18:36:00 #18] Initialised
cgimap-1    | [2024-04-29T18:36:00 #20] Initialised
lighttpd-1  | chmod: /dev/pts/0: No such file or directory
lighttpd-1  | 2024-04-29 18:36:01: (server.c.1568) server started (lighttpd/1.4.64)
web-1       | warning: parser/current is loading parser/ruby30, which recognizes 3.0.6-compliant syntax, but you are running 3.0.2.
web-1       | Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
web-1       | => Booting Puma
web-1       | => Rails 7.1.3.2 application starting in development 
web-1       | => Run `bin/rails server --help` for more startup options
web-1       | Puma starting in single mode...
web-1       | * Puma version: 5.6.8 (ruby 3.0.2-p107) ("Birdie's Version")
web-1       | *  Min threads: 5
web-1       | *  Max threads: 5
web-1       | *  Environment: development
web-1       | *          PID: 1
web-1       | * Listening on http://0.0.0.0:3000
web-1       | Use Ctrl-C to stop

In addition, when calling http://localhost:31500/api/0.6/node/1 the log should show something like: (assuming an empty database):

cgimap-1    | [2024-04-29T18:37:33 #11] Started request for node from 172.21.0.1
cgimap-1    | [2024-04-29T18:37:33 #11] Executed prepared statement select_nodes in 0 ms, returning 0 rows, 0 affected rows

Edit: you should also check if you have a common network defined on docker for all containers. This might be causing the connection refused errors you've been experiencing. That's more of a general Docker topic, though.