Score:0

docker-compose with nginx and nextcloud FPM stops accepting https connections

si flag

I have a fairly standard setup, with nginx as a web frontend (with https certiticates and such) and a nextcloud FPM backend; the whole installation has very low traffic, since I am the only one using it.

At one point https stops working, every connection from outside results in either timeout or connection refused; in this situation it seem that nextcloud is working and nginx isn't. I thought it may have to do with some energy saving on my host, but it's not the case, since all the other containers on the same host work just fine; the funny thing is that there is a simple way to make it work again and it is to open a shell on the host and do:

cd $NEXTCLOUD_DIRECTORY

where NEXTCLOUD_DIRECTORY is the base directory for the application, where both docker-compose.yml file and data directories are (located at $HOME/docker/nextcloud-letsencrypt).

I just don't understand why this is happening and why that operation is a solution...

Here is my compose file:

version: '3'
  services:
    nginx:
      image: nginx:alpine
      ports:
        - "80:80"
        - "127.0.0.1:8443:443"
      volumes:
        - ./data/nginx:/etc/nginx/conf.d
        - ./data/certbot/conf:/etc/letsencrypt
        - ./data/certbot/www:/var/www/certbot
        - ./data/nextcloud/www:/var/www/html:ro
        - ./data/nextcloud/apps:/var/www/html/custom_apps:ro
      restart: unless-stopped
      command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
    certbot:
      image: certbot/certbot
      volumes:
        - ./data/certbot/conf:/etc/letsencrypt
        - ./data/certbot/www:/var/www/certbot
      entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
      restart: unless-stopped
    cloud-db:
      container_name: ${DB_CONTAINER_NAME}
      image: mariadb:${DB_IMAGE_TAG}
      restart: unless-stopped
      command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
      volumes:
        ...
      environment:
        MYSQL_DATABASE: ${MYSQL_DATABASE}
        MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
        MYSQL_USER: ${MYSQL_USER}
        MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    app:
     image: nextcloud:21-fpm-alpine
     links:
       - cloud-db
     user: "1000:1004"
     volumes:
       - ./data/nextcloud/www:/var/www/html
       - ./data/nextcloud/apps:/var/www/html/custom_apps
       - ./data/nextcloud/config:/var/www/html/config
       - /mnt/usb/shared/nextcloud:/var/www/html/data
       - /mnt/usb/Expansion_2/serie:/mnt/serie:ro
       - /mnt/usb/archivio/archivio:/mnt/archivio:ro
     restart: unless-stopped

./data is in the root FS, inside user 1000's home directory.

/mnt/usb/shared/nextcloud is on an ext4 USB drive (ext4 defaults,nofail 0 0), R/W to the user

/mnt/usb/Expansion_2 is another ex4 USB drive (ext4 defaults,nofail 0 0) served through NC (they are registered as external storage in NC)

Michael Hampton avatar
cz flag
Did you do something strange like encrypt your home directory?
si flag
no, nothing like that; I actually noticed that the containers are recreated when I do the "cd" operation. They result created a minute ago or so. I think there's something wrong in my compose configuration rather than either nginx or nextcloud
Score:0
si flag

It seems that the solution is to use restart:always instead of "unless-stopped". I don't really know why I need that since no one is stopping the containers, so they should run indefinitely, like many other containers I have on the same machine that use "unless-stopped" and stay up indefinitely.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.