rsoper/richardsoper.me

MYSQL and Nextcloud

brimwats1 opened this issue · 12 comments

Just an update here--after a bunch of banging my head on this issue, nextcloud repeatedly fails I had a friend familiar with networks and MYSQL (day job as a programmer however) screenshare with me and we both threw lots of stuff at it to no avail.

when I go to set up nextcloud I use USERNAME/PASSWORD, and then

Data Folder: /var/www/html/data
Database User: nextcloud
DB Password = same password that's in MYSQL_PASSWORD: $$AREALPASSWORD and MYSQL_ROOT_PASSWORD: $$AREALPASSWORD (same for right now while I bug test)

I still get

SQLSTATE[HY000] [1045] Access denied for user 'nextcloud'@'nextcloud.traefik_proxy' (using password: YES)

What i've tried:

  • Getting on PHPMyAdmin and dropping the NextCloud Table and recreating it.
  • I rebuilt it using "MYSQL_HOST=mariadb:3306"
  • I've spent 3 hours trying variations on changing the passwords, docker-compose up and down and still getting the same error.
  • I tried making a mariadbuser who only used nextcloud.traefik_proxy

I'm self taught but I believe if nextcloud can't connect to your database it will fail to open and you can't log in. When I set up nextcloud I enter "mariadb:3306" and docker networking will direct it to the correct container. Some advice I have seen has said to just put mariadb in, which I've also done to no avail.

Here are my config bits for nextcloud and mariaDB

  # Nextcloud - Personal cloud storage system

  nextcloud:
    container_name: nextcloud
    image: nextcloud:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: $$AREALPASSWORD
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: $$AREALPASSWORD
      MYSQL_DATABASE: nextcloud
      MYSQL_HOST: mariadb
    env_file:
      - /home/$$USERNAME/Docker/example.env
    depends_on:
      - mariadb
    ports:
      - "8000:80"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nextcloud.entrypoints=http"
      - "traefik.http.routers.nextcloud.rule=Host(`cloud.$me.ME`)"
      - "traefik.http.middlewares.nextcloud-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.nextcloud.middlewares=nextcloud-https-redirect"
      - "traefik.http.routers.nextcloud-secure.entrypoints=https"
      - "traefik.http.routers.nextcloud-secure.rule=Host(`cloud.$me.ME`)"
      - "traefik.http.routers.nextcloud-secure.tls=true"
      - "traefik.http.routers.nextcloud-secure.tls.certresolver=cf-cert"
      - "traefik.http.routers.nextcloud-secure.service=nextcloud"
      - "traefik.http.middlewares.nextcloud-secure.headers.customFrameOptionsValue=SAMEORIGIN"
      - "traefik.http.middlewares.nextcloud-secure.headers.framedeny=true"
      - "traefik.http.middlewares.nextcloud-secure.headers.sslredirect=true"
      - "traefik.http.middlewares.nextcloud-secure.headers.stsIncludeSubdomains=true"
      - "traefik.http.middlewares.nextcloud-secure.headers.stsPreload=true"
      - "traefik.http.middlewares.nextcloud-secure.headers.stsSeconds=15552000"
      - "traefik.http.middlewares.nextcloud.headers.customFrameOptionsValue=SAMEORIGIN"
      - "traefik.http.middlewares.nextcloud.headers.framedeny=true"
      - "traefik.http.middlewares.nextcloud.headers.sslredirect=true"
      - "traefik.http.middlewares.nextcloud.headers.stsIncludeSubdomains=true"
      - "traefik.http.middlewares.nextcloud.headers.stsPreload=true"
      - "traefik.http.middlewares.nextcloud.headers.stsSeconds=15552000"
      - "traefik.http.services.nextcloud.loadbalancer.server.port=80"
      - "traefik.docker.network=traefik_proxy"
    volumes:
      - /home/$$USERNAME/Docker/nextcloud:/var/www/html
    networks:
      - traefik_proxy

  # MariaDB - SQL based database for most of this stack.

  mariadb:
    container_name: mariadb
    hostname: mariadb
    image: linuxserver/mariadb
    restart: always
    env_file:
      - /home/$$USERNAME/Docker/example.env
    volumes:
      - /home/$$USERNAME/Docker/mariadb:/config
      - /home/$$USERNAME/Docker/shared:/shared
    environment:
      - MYSQL_ROOT_PASSWORD=$$AREALPASSWORD
      - TZ="America/New_York"
    networks:
      - traefik_proxy

env file

# Directory level authentication
HTTP_USERNAME=myusername
HTTP_PASSWORD=passwordy$$

# My domain name
DOMAINNAME=$me.ME

# Cloudflare DNS authentication
CLOUDFLARE_EMAIL=REALEMAIL@gmail.com
CLOUDFLARE_API_KEY=$$REAL API

# Time Zone
TZ="America/New_York"

# Docker directory
DOCKERDIR=/home/$$USERNAME/Docker

# Database passwords
MYSQL_ROOT_PASSWORD=$$MYPASSWORD
WORDPRESSPW=$$MYPASSWORD

# Server IP
SERVER_IP=IP.ADDY.234234234

When I run docker-compose up and look at the logs nextcloud spits this out each time I fail to login:


nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:48:46 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | [Sat Feb 08 23:48:46.323607 2020] [core:alert] [pid 417] [client 172.19.0.2:42790] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | [Sat Feb 08 23:48:46.488266 2020] [core:alert] [pid 31] [client 172.19.0.2:42794] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:48:46 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:48:45 +0000] "POST /index.php HTTP/1.1" 200 3630 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:49:12 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | [Sat Feb 08 23:49:12.113201 2020] [core:alert] [pid 28] [client 172.19.0.2:42806] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | [Sat Feb 08 23:49:12.290454 2020] [core:alert] [pid 32] [client 172.19.0.2:42810] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:49:12 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:49:11 +0000] "POST /index.php HTTP/1.1" 200 3632 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
nextcloud     | [Sat Feb 08 23:56:46.645678 2020] [core:alert] [pid 416] [client 172.19.0.2:42846] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:56:46 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | [Sat Feb 08 23:56:46.762260 2020] [core:alert] [pid 29] [client 172.19.0.2:42850] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:56:46 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:56:46 +0000] "GET / HTTP/1.1" 200 2704 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
nextcloud     | [Sat Feb 08 23:59:07.477249 2020] [core:alert] [pid 417] [client 172.19.0.2:42872] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:59:07 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | [Sat Feb 08 23:59:07.612137 2020] [core:alert] [pid 31] [client 172.19.0.2:42876] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:59:07 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | 172.19.0.2 - - [08/Feb/2020:23:59:07 +0000] "GET /index.php/csrftoken HTTP/1.1" 200 2702 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0"
nextcloud     | [Sun Feb 09 00:02:12.207587 2020] [core:alert] [pid 28] [client 172.19.0.2:42900] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | 172.19.0.2 - - [09/Feb/2020:00:02:12 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | 172.19.0.2 - - [09/Feb/2020:00:02:12 +0000] "GET /data/htaccesstest.txt HTTP/1.1" 500 807 "-" "Nextcloud Server Crawler"
nextcloud     | [Sun Feb 09 00:02:12.309546 2020] [core:alert] [pid 32] [client 172.19.0.2:42904] /var/www/html/data/.htaccess: Expected </IifModule> but saw </IfModule>
nextcloud     | 172.19.0.2 - - [09/Feb/2020:00:02:11 +0000] "GET /index.php/csrftoken HTTP/1.1" 200 2702 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0"

oh there's also an error at the beginning from phpmyadmin nextcloud wordpress and ghost about not knowing the server name and wanting ServerName, but the other services work fine.

Are you able to get nextcloud to startup and go to the in browser config without the mysql environment tags?

@rsoper confirmed that it still fails! different error however:

SQLSTATE[HY000] [2002] No such file or directory

I tried running this with
DB User nextcloud
pw nextcloud
db name: nextcloud

for the last field I tried localhost, localhost:3306, mariadb, and mariadb:3306

Some other attempts get the usual error:

SQLSTATE[HY000] [1045] Access denied for user 'nextcloud'@'172.19.0.9' (using password: YES)

terminal has a different IP but i doubt that matters:

nextcloud | 172.19.0.2 - - [13/Feb/2020:00:41:34 +0000] "GET /core/css/guest.css?v=ba222ded25d957b900c03bef914333cd HTTP/1.1" 200 5818 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0"

last update, promose: installing postgre via porttainer and choosing that seems to work fine... 🤔 does that info give you any insight?

I wonder if its Ubuntu permissions issues? Or perhaps DNSMASQ is still enabled? My primary server is macOS with docker desktop, and while getting my rPi(raspbian buster lite) ready to take over it didnt run into any database connection issues either. On the rPi I know I only referred to the database host as "mariadb" as well.

No worries if you don't know, but off the top of your head what folder or what would I need to give permission to/for?

I'll take a peek at DNSMASQ!

I've confirmed that DNSMASQ does not seem to be enabled on ubuntu. The permissions I have on my mariadb are:

ls -la mariadb/
total 24
drwxrwxr-x 4 911 911 4096 Feb 7 20:27 .
drwxr-xr-x 15 COMPNAME COMPNAME 4096 Feb 12 20:49 ..
-rw-r--r-- 1 911 911 3754 Feb 7 20:27 custom.cnf
drwxr-xr-x 7 911 911 4096 Feb 23 15:02 databases
-rw-rw-r-- 1 911 911 14 Feb 7 14:32 .gitignore drwxr-xr-x 3 911 911 4096 Feb 7 20:27 log

Interesting. Thats what it looks like on both of my systems. I honestly can't think of what else would be causing that. With the hostname declaration in the docker-compose file and both containers living on the same network it should be as simple as specifying "mariadb" as your host and the table, user, and password to go along with it. Im afraid Im not quite sure what else to check. At least not without direct access to the affected system.

Well glad to hear you got something working. Cheers!