Docker -> Nginx -> Nextcloud - Page not found

Hi everyone,

after setting up the above on Rocky Linux / Docker, I am still having issues to make nextcloud properly accessible through nginx. It may be a basic mistake on my end, but I am struggling to spot it, after days of research. So I am hoping for help on here :wink:

SSL / https is properly set up, certificates are working, connections are considered secure by Chrome / Firefox.
https://mydomain.xyz works fine, redirecting to nginx welcome page.
But: I am seeing the redirect from nginx to /cloud itself working fine, nextcloud is loading, but only partially it seems:

Nextcloud
Page not found
The page could not be found on the server.

I can see in Chrome / Firefox when investigating page network traffic, that GET requests are not resolved an result in a 404, such as "https://mydomain.xyz/cloud/dist/core-main.js?v=d2d6a38d-0

I am wondering if there are any obvious issues that can be seen in my configs, and appreciate any help:

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'xyz',
  'passwordsalt' => 'xyz',
  'secret' => 'xyz',
  'trusted_proxies' => ['172.17.0.2'],
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'sqlite3',
  'version' => '26.0.2.1',
  'overwrite.cli.url' => 'https://mydomain.xyz/',
'overwritewebprotocol' => 'https',
  'installed' => true,
);

nginx.conf:

server {
    listen 443 ssl;
    server_name mydomain.xyz;
    ssl_certificate /etc/letsencrypt/live/mydomain.xyz/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain.xyz/privkey.pem;

    listen 80;
    listen [::]:80;
    access_log /var/log/nginx/host.access.log main;

    location / {
        root /usr/share/nginx/html;
        index index.html index.htm;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location /cloud {
        proxy_pass http://172.17.0.4:80/cloud;
    }
}

Thanks a lot!
Christian

It appears you’re trying to use the above NGINX configuration only for reverse proxy purposes, so what is your Nextcloud instance using as a web server? And how did you configure it?

It might be helpful to also understand where you’re coming from so: what installation approach did you take for Nextcloud? Is your Nextcloud instance in a Docker container as well? If so, post the Docker Compose file.

Hi jrt,

Of course. So, pulled the official nextcloud docker image, which comes with apache2. I did not configure it at all, since it is completely fresh setup, and I never came past that issue. So we can assume everything nextcloud being pretty much standard at the moment.

No docker compose file, just pulled the image and ran the container. Also using portainer for container management.

Later on, I am planning to run nginx as webserver for Wordpress as well.

Cheers
Christian

I am thinking it may have to do with how requests and paths are forwarded from nginx to nextcloud, and / or how they are processed within nextcloud.

When I am adding to my nextcloud config.php:

'overwrite.cli.url' => 'https://mydomain.com/',

and restart the nextcloud container, I can see that GET https://mydomain.com/cloud/login gets a 200 OK, but everything else receives a 404 Not found, such as GET https://mydomain.com/apps/files_rightclick/css/app.css?v=35c36e89-0. The request is missing /cloud/ after the domain.

How did you run the container? With what parameters? (I assume you’re just testing because you won’t get very far without a persistent data volume attached to the container).

What about your database container? What are you using?

Also post the last few entries of your nextcloud.log from the Nextcloud container.

Alternatively, if you’d rather use a more turnkey Nextcloud stack that is container based you may want to check out the All-In-One image.

1 Like

How did you run the container? With what parameters? (I assume you’re just testing because you won’t get very far without a persistent data volume attached to the container).

docker run -d -p 8080:80 nextcloud

What about your database container? What are you using?

No dedicated one, but I could see nextcloud suggested / used SQLite on initial launch. I am planning to get to that, once the reverse proxy setup works as it should.

Also post the last few entries of your nextcloud.log from the Nextcloud container.

Had to set up logging, here is the output for DEBUG:

{
  "reqId": "ZnG4iTU6P6lB6RckTNqz",
  "level": 3,
  "time": "2023-06-07T16:02:51+00:00",
  "remoteAddr": "94.31.105.125",
  "user": "cru",
  "app": "no app in context",
  "method": "PUT",
  "url": "/ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json",
  "message": "An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: oc_user_status.user_id",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
  "version": "26.0.2.1",
  "exception": {
    "Exception": "OC\\DB\\Exceptions\\DbalException",
    "Message": "An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: oc_user_status.user_id",
    "Code": 19,
    "Trace": [
      {
        "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
        "line": 328,
        "function": "wrap",
        "class": "OC\\DB\\Exceptions\\DbalException",
        "type": "::",
        "args": [
          [
            "Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
        "line": 138,
        "function": "executeStatement",
        "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/apps/user_status/lib/Listener/UserLiveStatusListener.php",
        "line": 104,
        "function": "insert",
        "class": "OCP\\AppFramework\\Db\\QBMapper",
        "type": "->",
        "args": [
          [
            "OCA\\UserStatus\\Db\\UserStatus",
            null,
            "cru",
            "online",
            1686153771,
            false,
            null,
            null,
            null,
            null,
            null
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php",
        "line": 86,
        "function": "handle",
        "class": "OCA\\UserStatus\\Listener\\UserLiveStatusListener",
        "type": "->",
        "args": [
          [
            "OCP\\User\\Events\\UserLiveStatusEvent"
          ]
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 251,
        "function": "__invoke",
        "class": "OC\\EventDispatcher\\ServiceEventListener",
        "type": "->",
        "args": [
          [
            "OCP\\User\\Events\\UserLiveStatusEvent"
          ],
          "OCP\\User\\Events\\UserLiveStatusEvent",
          [
            "Symfony\\Component\\EventDispatcher\\EventDispatcher"
          ]
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 73,
        "function": "callListeners",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            [
              "Closure"
            ]
          ],
          "OCP\\User\\Events\\UserLiveStatusEvent",
          [
            "OCP\\User\\Events\\UserLiveStatusEvent"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 87,
        "function": "dispatch",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            "OCP\\User\\Events\\UserLiveStatusEvent"
          ],
          "OCP\\User\\Events\\UserLiveStatusEvent"
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 99,
        "function": "dispatch",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          "OCP\\User\\Events\\UserLiveStatusEvent",
          [
            "OCP\\User\\Events\\UserLiveStatusEvent"
          ]
        ]
      },
      {
        "file": "/var/www/html/apps/user_status/lib/Controller/HeartbeatController.php",
        "line": 91,
        "function": "dispatchTyped",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            "OCP\\User\\Events\\UserLiveStatusEvent"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 230,
        "function": "heartbeat",
        "class": "OCA\\UserStatus\\Controller\\HeartbeatController",
        "type": "->",
        "args": [
          "online"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 137,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          [
            "OCA\\UserStatus\\Controller\\HeartbeatController"
          ],
          "heartbeat"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/App.php",
        "line": 183,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          [
            "OCA\\UserStatus\\Controller\\HeartbeatController"
          ],
          "heartbeat"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Route/Router.php",
        "line": 315,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\UserStatus\\Controller\\HeartbeatController",
          "heartbeat",
          [
            "OC\\AppFramework\\DependencyInjection\\DIContainer"
          ],
          [
            "ocs.user_status.Heartbeat.heartbeat"
          ]
        ]
      },
      {
        "file": "/var/www/html/ocs/v1.php",
        "line": 64,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/ocsapp/apps/user_status/api/v1/heartbeat"
        ]
      },
      {
        "file": "/var/www/html/ocs/v2.php",
        "line": 23,
        "args": [
          "/var/www/html/ocs/v1.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/var/www/html/lib/private/DB/Exceptions/DbalException.php",
    "Line": 71,
    "Previous": {
      "Exception": "Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException",
      "Message": "An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: oc_user_status.user_id",
      "Code": 19,
      "Trace": [
        {
          "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
          "line": 1814,
          "function": "convert",
          "class": "Doctrine\\DBAL\\Driver\\API\\SQLite\\ExceptionConverter",
          "type": "->",
          "args": [
            [
              "Doctrine\\DBAL\\Driver\\PDO\\Exception"
            ],
            [
              "Doctrine\\DBAL\\Query"
            ]
          ]
        },
        {
          "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
          "line": 1749,
          "function": "handleDriverException",
          "class": "Doctrine\\DBAL\\Connection",
          "type": "->",
          "args": [
            [
              "Doctrine\\DBAL\\Driver\\PDO\\Exception"
            ],
            [
              "Doctrine\\DBAL\\Query"
            ]
          ]
        },
        {
          "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
          "line": 1163,
          "function": "convertExceptionDuringQuery",
          "class": "Doctrine\\DBAL\\Connection",
          "type": "->",
          "args": [
            [
              "Doctrine\\DBAL\\Driver\\PDO\\Exception"
            ],
            "INSERT INTO \"oc_user_status\" (\"user_id\", \"status\", \"status_timestamp\", \"is_user_defined\") VALUES(?, ?, ?, ?)",
            [
              "cru",
              "online",
              1686153771,
              false
            ],
            [
              2,
              2,
              1,
              5
            ]
          ]
        },
        {
          "file": "/var/www/html/lib/private/DB/Connection.php",
          "line": 295,
          "function": "executeStatement",
          "class": "Doctrine\\DBAL\\Connection",
          "type": "->",
          "args": [
            "INSERT INTO \"oc_user_status\" (\"user_id\", \"status\", \"status_timestamp\", \"is_user_defined\") VALUES(?, ?, ?, ?)",
            [
              "cru",
              "online",
              1686153771,
              false
            ],
            [
              2,
              2,
              1,
              5
            ]
          ]
        },
        {
          "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php",
          "line": 354,
          "function": "executeStatement",
          "class": "OC\\DB\\Connection",
          "type": "->",
          "args": [
            "INSERT INTO \"oc_user_status\" (\"user_id\", \"status\", \"status_timestamp\", \"is_user_defined\") VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4)",
            [
              "cru",
              "online",
              1686153771,
              false
            ],
            [
              2,
              2,
              1,
              5
            ]
          ]
        },
        {
          "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
          "line": 280,
          "function": "execute",
          "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
          "line": 326,
          "function": "execute",
          "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
          "line": 138,
          "function": "executeStatement",
          "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/html/apps/user_status/lib/Listener/UserLiveStatusListener.php",
          "line": 104,
          "function": "insert",
          "class": "OCP\\AppFramework\\Db\\QBMapper",
          "type": "->",
          "args": [
            [
              "OCA\\UserStatus\\Db\\UserStatus",
              null,
              "cru",
              "online",
              1686153771,
              false,
              null,
              null,
              null,
              null,
              null
            ]
          ]
        },
        {
          "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php",
          "line": 86,
          "function": "handle",
          "class": "OCA\\UserStatus\\Listener\\UserLiveStatusListener",
          "type": "->",
          "args": [
            [
              "OCP\\User\\Events\\UserLiveStatusEvent"
            ]
          ]
        },
        {
          "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
          "line": 251,
          "function": "__invoke",
          "class": "OC\\EventDispatcher\\ServiceEventListener",
          "type": "->",
          "args": [
            [
              "OCP\\User\\Events\\UserLiveStatusEvent"
            ],
            "OCP\\User\\Events\\UserLiveStatusEvent",
            [
              "Symfony\\Component\\EventDispatcher\\EventDispatcher"
            ]
          ]
        },
        {
          "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
          "line": 73,
          "function": "callListeners",
          "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
          "type": "->",
          "args": [
            [
              [
                "Closure"
              ]
            ],
            "OCP\\User\\Events\\UserLiveStatusEvent",
            [
              "OCP\\User\\Events\\UserLiveStatusEvent"
            ]
          ]
        },
        {
          "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
          "line": 87,
          "function": "dispatch",
          "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
          "type": "->",
          "args": [
            [
              "OCP\\User\\Events\\UserLiveStatusEvent"
            ],
            "OCP\\User\\Events\\UserLiveStatusEvent"
          ]
        },
        {
          "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
          "line": 99,
          "function": "dispatch",
          "class": "OC\\EventDispatcher\\EventDispatcher",
          "type": "->",
          "args": [
            "OCP\\User\\Events\\UserLiveStatusEvent",
            [
              "OCP\\User\\Events\\UserLiveStatusEvent"
            ]
          ]
        },
        {
          "file": "/var/www/html/apps/user_status/lib/Controller/HeartbeatController.php",
          "line": 91,
          "function": "dispatchTyped",
          "class": "OC\\EventDispatcher\\EventDispatcher",
          "type": "->",
          "args": [
            [
              "OCP\\User\\Events\\UserLiveStatusEvent"
            ]
          ]
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 230,
          "function": "heartbeat",
          "class": "OCA\\UserStatus\\Controller\\HeartbeatController",
          "type": "->",
          "args": [
            "online"
          ]
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 137,
          "function": "executeController",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->",
          "args": [
            [
              "OCA\\UserStatus\\Controller\\HeartbeatController"
            ],
            "heartbeat"
          ]
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/App.php",
          "line": 183,
          "function": "dispatch",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->",
          "args": [
            [
              "OCA\\UserStatus\\Controller\\HeartbeatController"
            ],
            "heartbeat"
          ]
        },
        {
          "file": "/var/www/html/lib/private/Route/Router.php",
          "line": 315,
          "function": "main",
          "class": "OC\\AppFramework\\App",
          "type": "::",
          "args": [
            "OCA\\UserStatus\\Controller\\HeartbeatController",
            "heartbeat",
            [
              "OC\\AppFramework\\DependencyInjection\\DIContainer"
            ],
            [
              "ocs.user_status.Heartbeat.heartbeat"
            ]
          ]
        },
        {
          "file": "/var/www/html/ocs/v1.php",
          "line": 64,
          "function": "match",
          "class": "OC\\Route\\Router",
          "type": "->",
          "args": [
            "/ocsapp/apps/user_status/api/v1/heartbeat"
          ]
        },
        {
          "file": "/var/www/html/ocs/v2.php",
          "line": 23,
          "args": [
            "/var/www/html/ocs/v1.php"
          ],
          "function": "require_once"
        }
      ],
      "File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php",
      "Line": 44,
      "Previous": {
        "Exception": "Doctrine\\DBAL\\Driver\\PDO\\Exception",
        "Message": "SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: oc_user_status.user_id",
        "Code": 19,
        "Trace": [
          {
            "file": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php",
            "line": 103,
            "function": "new",
            "class": "Doctrine\\DBAL\\Driver\\PDO\\Exception",
            "type": "::",
            "args": [
              [
                "PDOException",
                [
                  "23000",
                  19,
                  "UNIQUE constraint failed: oc_user_status.user_id"
                ]
              ]
            ]
          },
          {
            "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
            "line": 1153,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Driver\\PDO\\Statement",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/html/lib/private/DB/Connection.php",
            "line": 295,
            "function": "executeStatement",
            "class": "Doctrine\\DBAL\\Connection",
            "type": "->",
            "args": [
              "INSERT INTO \"oc_user_status\" (\"user_id\", \"status\", \"status_timestamp\", \"is_user_defined\") VALUES(?, ?, ?, ?)",
              [
                "cru",
                "online",
                1686153771,
                false
              ],
              [
                2,
                2,
                1,
                5
              ]
            ]
          },
          {
            "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php",
            "line": 354,
            "function": "executeStatement",
            "class": "OC\\DB\\Connection",
            "type": "->",
            "args": [
              "INSERT INTO \"oc_user_status\" (\"user_id\", \"status\", \"status_timestamp\", \"is_user_defined\") VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4)",
              [
                "cru",
                "online",
                1686153771,
                false
              ],
              [
                2,
                2,
                1,
                5
              ]
            ]
          },
          {
            "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
            "line": 280,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
            "line": 326,
            "function": "execute",
            "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
            "line": 138,
            "function": "executeStatement",
            "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/html/apps/user_status/lib/Listener/UserLiveStatusListener.php",
            "line": 104,
            "function": "insert",
            "class": "OCP\\AppFramework\\Db\\QBMapper",
            "type": "->",
            "args": [
              [
                "OCA\\UserStatus\\Db\\UserStatus",
                null,
                "cru",
                "online",
                1686153771,
                false,
                null,
                null,
                null,
                null,
                null
              ]
            ]
          },
          {
            "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php",
            "line": 86,
            "function": "handle",
            "class": "OCA\\UserStatus\\Listener\\UserLiveStatusListener",
            "type": "->",
            "args": [
              [
                "OCP\\User\\Events\\UserLiveStatusEvent"
              ]
            ]
          },
          {
            "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
            "line": 251,
            "function": "__invoke",
            "class": "OC\\EventDispatcher\\ServiceEventListener",
            "type": "->",
            "args": [
              [
                "OCP\\User\\Events\\UserLiveStatusEvent"
              ],
              "OCP\\User\\Events\\UserLiveStatusEvent",
              [
                "Symfony\\Component\\EventDispatcher\\EventDispatcher"
              ]
            ]
          },
          {
            "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
            "line": 73,
            "function": "callListeners",
            "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
            "type": "->",
            "args": [
              [
                [
                  "Closure"
                ]
              ],
              "OCP\\User\\Events\\UserLiveStatusEvent",
              [
                "OCP\\User\\Events\\UserLiveStatusEvent"
              ]
            ]
          },
          {
            "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
            "line": 87,
            "function": "dispatch",
            "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
            "type": "->",
            "args": [
              [
                "OCP\\User\\Events\\UserLiveStatusEvent"
              ],
              "OCP\\User\\Events\\UserLiveStatusEvent"
            ]
          },
          {
            "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
            "line": 99,
            "function": "dispatch",
            "class": "OC\\EventDispatcher\\EventDispatcher",
            "type": "->",
            "args": [
              "OCP\\User\\Events\\UserLiveStatusEvent",
              [
                "OCP\\User\\Events\\UserLiveStatusEvent"
              ]
            ]
          },
          {
            "file": "/var/www/html/apps/user_status/lib/Controller/HeartbeatController.php",
            "line": 91,
            "function": "dispatchTyped",
            "class": "OC\\EventDispatcher\\EventDispatcher",
            "type": "->",
            "args": [
              [
                "OCP\\User\\Events\\UserLiveStatusEvent"
              ]
            ]
          },
          {
            "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
            "line": 230,
            "function": "heartbeat",
            "class": "OCA\\UserStatus\\Controller\\HeartbeatController",
            "type": "->",
            "args": [
              "online"
            ]
          },
          {
            "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
            "line": 137,
            "function": "executeController",
            "class": "OC\\AppFramework\\Http\\Dispatcher",
            "type": "->",
            "args": [
              [
                "OCA\\UserStatus\\Controller\\HeartbeatController"
              ],
              "heartbeat"
            ]
          },
          {
            "file": "/var/www/html/lib/private/AppFramework/App.php",
            "line": 183,
            "function": "dispatch",
            "class": "OC\\AppFramework\\Http\\Dispatcher",
            "type": "->",
            "args": [
              [
                "OCA\\UserStatus\\Controller\\HeartbeatController"
              ],
              "heartbeat"
            ]
          },
          {
            "file": "/var/www/html/lib/private/Route/Router.php",
            "line": 315,
            "function": "main",
            "class": "OC\\AppFramework\\App",
            "type": "::",
            "args": [
              "OCA\\UserStatus\\Controller\\HeartbeatController",
              "heartbeat",
              [
                "OC\\AppFramework\\DependencyInjection\\DIContainer"
              ],
              [
                "ocs.user_status.Heartbeat.heartbeat"
              ]
            ]
          },
          {
            "file": "/var/www/html/ocs/v1.php",
            "line": 64,
            "function": "match",
            "class": "OC\\Route\\Router",
            "type": "->",
            "args": [
              "/ocsapp/apps/user_status/api/v1/heartbeat"
            ]
          },
          {
            "file": "/var/www/html/ocs/v2.php",
            "line": 23,
            "args": [
              "/var/www/html/ocs/v1.php"
            ],
            "function": "require_once"
          }
        ],
        "File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php",
        "Line": 30,
        "Previous": {
          "Exception": "PDOException",
          "Message": "SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: oc_user_status.user_id",
          "Code": "23000",
          "Trace": [
            {
              "file": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php",
              "line": 101,
              "function": "execute",
              "class": "PDOStatement",
              "type": "->",
              "args": [
                null
              ]
            },
            {
              "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
              "line": 1153,
              "function": "execute",
              "class": "Doctrine\\DBAL\\Driver\\PDO\\Statement",
              "type": "->",
              "args": []
            },
            {
              "file": "/var/www/html/lib/private/DB/Connection.php",
              "line": 295,
              "function": "executeStatement",
              "class": "Doctrine\\DBAL\\Connection",
              "type": "->",
              "args": [
                "INSERT INTO \"oc_user_status\" (\"user_id\", \"status\", \"status_timestamp\", \"is_user_defined\") VALUES(?, ?, ?, ?)",
                [
                  "cru",
                  "online",
                  1686153771,
                  false
                ],
                [
                  2,
                  2,
                  1,
                  5
                ]
              ]
            },
            {
              "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php",
              "line": 354,
              "function": "executeStatement",
              "class": "OC\\DB\\Connection",
              "type": "->",
              "args": [
                "INSERT INTO \"oc_user_status\" (\"user_id\", \"status\", \"status_timestamp\", \"is_user_defined\") VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4)",
                [
                  "cru",
                  "online",
                  1686153771,
                  false
                ],
                [
                  2,
                  2,
                  1,
                  5
                ]
              ]
            },
            {
              "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
              "line": 280,
              "function": "execute",
              "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
              "type": "->",
              "args": []
            },
            {
              "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
              "line": 326,
              "function": "execute",
              "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
              "type": "->",
              "args": []
            },
            {
              "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
              "line": 138,
              "function": "executeStatement",
              "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
              "type": "->",
              "args": []
            },
            {
              "file": "/var/www/html/apps/user_status/lib/Listener/UserLiveStatusListener.php",
              "line": 104,
              "function": "insert",
              "class": "OCP\\AppFramework\\Db\\QBMapper",
              "type": "->",
              "args": [
                [
                  "OCA\\UserStatus\\Db\\UserStatus",
                  null,
                  "cru",
                  "online",
                  1686153771,
                  false,
                  null,
                  null,
                  null,
                  null,
                  null
                ]
              ]
            },
            {
              "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php",
              "line": 86,
              "function": "handle",
              "class": "OCA\\UserStatus\\Listener\\UserLiveStatusListener",
              "type": "->",
              "args": [
                [
                  "OCP\\User\\Events\\UserLiveStatusEvent"
                ]
              ]
            },
            {
              "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
              "line": 251,
              "function": "__invoke",
              "class": "OC\\EventDispatcher\\ServiceEventListener",
              "type": "->",
              "args": [
                [
                  "OCP\\User\\Events\\UserLiveStatusEvent"
                ],
                "OCP\\User\\Events\\UserLiveStatusEvent",
                [
                  "Symfony\\Component\\EventDispatcher\\EventDispatcher"
                ]
              ]
            },
            {
              "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
              "line": 73,
              "function": "callListeners",
              "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
              "type": "->",
              "args": [
                [
                  [
                    "Closure"
                  ]
                ],
                "OCP\\User\\Events\\UserLiveStatusEvent",
                [
                  "OCP\\User\\Events\\UserLiveStatusEvent"
                ]
              ]
            },
            {
              "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
              "line": 87,
              "function": "dispatch",
              "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
              "type": "->",
              "args": [
                [
                  "OCP\\User\\Events\\UserLiveStatusEvent"
                ],
                "OCP\\User\\Events\\UserLiveStatusEvent"
              ]
            },
            {
              "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
              "line": 99,
              "function": "dispatch",
              "class": "OC\\EventDispatcher\\EventDispatcher",
              "type": "->",
              "args": [
                "OCP\\User\\Events\\UserLiveStatusEvent",
                [
                  "OCP\\User\\Events\\UserLiveStatusEvent"
                ]
              ]
            },
            {
              "file": "/var/www/html/apps/user_status/lib/Controller/HeartbeatController.php",
              "line": 91,
              "function": "dispatchTyped",
              "class": "OC\\EventDispatcher\\EventDispatcher",
              "type": "->",
              "args": [
                [
                  "OCP\\User\\Events\\UserLiveStatusEvent"
                ]
              ]
            },
            {
              "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
              "line": 230,
              "function": "heartbeat",
              "class": "OCA\\UserStatus\\Controller\\HeartbeatController",
              "type": "->",
              "args": [
                "online"
              ]
            },
            {
              "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
              "line": 137,
              "function": "executeController",
              "class": "OC\\AppFramework\\Http\\Dispatcher",
              "type": "->",
              "args": [
                [
                  "OCA\\UserStatus\\Controller\\HeartbeatController"
                ],
                "heartbeat"
              ]
            },
            {
              "file": "/var/www/html/lib/private/AppFramework/App.php",
              "line": 183,
              "function": "dispatch",
              "class": "OC\\AppFramework\\Http\\Dispatcher",
              "type": "->",
              "args": [
                [
                  "OCA\\UserStatus\\Controller\\HeartbeatController"
                ],
                "heartbeat"
              ]
            },
            {
              "file": "/var/www/html/lib/private/Route/Router.php",
              "line": 315,
              "function": "main",
              "class": "OC\\AppFramework\\App",
              "type": "::",
              "args": [
                "OCA\\UserStatus\\Controller\\HeartbeatController",
                "heartbeat",
                [
                  "OC\\AppFramework\\DependencyInjection\\DIContainer"
                ],
                [
                  "ocs.user_status.Heartbeat.heartbeat"
                ]
              ]
            },
            {
              "file": "/var/www/html/ocs/v1.php",
              "line": 64,
              "function": "match",
              "class": "OC\\Route\\Router",
              "type": "->",
              "args": [
                "/ocsapp/apps/user_status/api/v1/heartbeat"
              ]
            },
            {
              "file": "/var/www/html/ocs/v2.php",
              "line": 23,
              "args": [
                "/var/www/html/ocs/v1.php"
              ],
              "function": "require_once"
            }
          ],
          "File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php",
          "Line": 101
        }
      }
    },
    "CustomMessage": "--"
  }
}

Alternatively, if you’d rather use a more turnkey Nextcloud stack that is container based you may want to check out the All-In-One image.

Thank you for pointing me to that. However, since I will be operating this, I think I should build some knowledge around the subject, to also be able to troubleshoot etc…

docker run -d -p 8080:80 nextcloud

This suggests you’ll need to change your NGINX config from:

proxy_pass http://172.17.0.4:80/cloud;

to:

proxy_pass http://172.17.0.4:8080/cloud;

This assumes you’ve got your Docker network configuration functioning between your proxy container and the Nextcloud container. With the way you’re running it, 8080 should be available from the host network so as long as your proxy uses that, it should work.

I did the change, restarted nextcloud container, reloaded nginx. Here is what happens when I load https://mydomain.com/cloud

GET https://mydomain.com/cloud -> 302 Moved Temporarily
GET https://mydomain.com/cloud/ -> 502 Bad Gateway
GET	https://mydomain.com/favicon.ico -> 404 Not Found

When I curl within the nginx container to http://172.17.0.4:8080/ it also says connection refused. My guess is that as soon as I redirect to 172.17.0.4 (which is the IP of the nextcloud container), I should reach it rather on port 80 than on 8080. P.S.: I can reach 172.17.0.1:8080 fine, which is the docker IPV4 gateway.

The 302 comes from me adding to the nginx config:

location = /cloud {
        return 302 /cloud/;
}

Solved this by switching to caddy server. Simple handle_path directive did the trick.
Cheers

1 Like