Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
maximumwarp
Posts: 7
Joined: Sun Jul 21, 2019 7:35 pm

Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by maximumwarp »

Hi,
I installed via dietpi-software Nexcloud. It seems to run well but in settings I have two warnings about ocm-provider and ocs-provider. On my Pi I use a LAMP stack and I configured Nextcloud with nextcloud.mydomain.tld.
This is my Apache2 virtual host file for Nextcloud:

Code: Select all

<VirtualHost *:80>
  ServerName mydomain.tld
  ServerAdmin admin@mydomain.tld
  DocumentRoot /var/www/nextcloud
  <Directory /var/www/nextcloud>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews
    SetEnv HOME /var/www/nextcloud
    SetEnv HTTP_HOME /var/www/nextcloud
  </Directory>
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  RewriteEngine on
  RewriteCond %{SERVER_NAME} =nextcloud.mydomain.tld
  RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
adding

Code: Select all

# Redirect OCM/OCS provider requests to Nextcloud endpoint:
Redirect permanent /ocm-provider /nextcloud/ocm-provider
Redirect permanent /ocs-provider /nextcloud/ocs-provider
doesn't solve the problem.

Can anyone help me?
User avatar
MichaIng
Site Admin
Posts: 3105
Joined: Sat Nov 18, 2017 6:21 pm

Re: Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by MichaIng »

@maximumwarp
It looks like you want Nextcloud being reachable without subdir, right?
In this case no redirect rules are required, even wrong, redirecting to non-existent paths.
If you installed Nextcloud via dietpi-software and just edited the default vhost, then you must disable the drop-in config that we place to set the right rules for /nextcloud subdir: Removing the redirect lines you added and running a2dissite dietpi-nextcloud && systemctl reload apache2 should resolve the issue.

Note:
Redirect permanent /ocm-provider /nextcloud/ocm-provider
This means that all requests to /ocm-provider path, relative to the webroot, are redirected to /nextcloud/ocm-provider subdir, relative to the webroot. Since you webroot is /var/www/nextcloud, this means:
/var/www/nextcloud/ocm-provider is redirected to /var/www/nextcloud/nextcloud/ocm-provider, while the first path is already correct and the second does not even exist ;).
bbkhdt
Posts: 9
Joined: Sun Mar 14, 2021 6:29 pm

Re: Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by bbkhdt »

Hey,

I tried to use the template given in the op to create a virtualhost configuration file for my dietpi-nextcloud:

Code: Select all

<VirtualHost *:80>
    ServerName cloud.***.de
    DocumentRoot /var/www/nextcloud

    <Directory /var/www/nextcloud>
        Require all granted
        AllowOverride All
        Options FollowSymLinks MultiViews

        <IfModule mod_dav.c>
                Dav off
        </IfModule>

        # https://github.com/MichaIng/DietPi/issues/3694
        Header unset Content-Security-Policy
        Header always unset Content-Security-Policy
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    #CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
With the config above I get to "http://cloud.***.de/login" and get an Intgernal Server Error page:
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
I added my domain to the trusted sites in the config.php file. Additionally I set the 'overwrite.cli.url' to the domain given above and 'htaccess.RewriteBase' to '/'.

I'm sure I'm some essential step. Some help would be much appreciated.
User avatar
MichaIng
Site Admin
Posts: 3105
Joined: Sat Nov 18, 2017 6:21 pm

Re: Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by MichaIng »

The default vhosts are all disabled? Did you try to create a test file, like /var/www/nextcloud/test.html and access that, like cloud.domain.de/test.html?
bbkhdt
Posts: 9
Joined: Sun Mar 14, 2021 6:29 pm

Re: Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by bbkhdt »

Hi!

thanks for the quick reply.

1. Yes, I disabled all other vitualhost conf files that I found in /etc/apache2/sites-available/ by calling a2dissite <CONFIG-FILE>

2. No I had not previously tried to place an html file into /var/www/nextcloud/. I have tried that now, the file content was only "Hello World" without any markup.

I still get the error mentioned in my first post. :(

However, the font of the error message has changed after adding test.html.
User avatar
MichaIng
Site Admin
Posts: 3105
Joined: Sat Nov 18, 2017 6:21 pm

Re: Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by MichaIng »

Okay, then it's a webserver issue, not PHP/Nextcloud issue.

Can you show the result of:

Code: Select all

journalctl -u apache2
bbkhdt
Posts: 9
Joined: Sun Mar 14, 2021 6:29 pm

Re: Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by bbkhdt »

Here's (last bit of) the output of journalctl -u apache2

Code: Select all

Mar 14 17:59:07 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Mar 14 17:59:59 DietPi systemd[1]: Reloading The Apache HTTP Server.
Mar 14 17:59:59 DietPi apachectl[3376]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to s
uppress this message
Mar 14 17:59:59 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Mar 14 18:13:53 DietPi systemd[1]: Reloading The Apache HTTP Server.
Mar 14 18:13:53 DietPi apachectl[4717]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to s
uppress this message
Mar 14 18:13:53 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Mar 15 08:16:05 DietPi systemd[1]: Reloading The Apache HTTP Server.
Mar 15 08:16:05 DietPi apachectl[8332]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to s
uppress this message
Mar 15 08:16:05 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Mar 15 08:28:23 DietPi systemd[1]: Reloading The Apache HTTP Server.
Mar 15 08:28:23 DietPi apachectl[8469]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to s
uppress this message
Mar 15 08:28:23 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Mar 15 08:45:12 DietPi systemd[1]: Stopping The Apache HTTP Server...
Mar 15 08:45:16 DietPi systemd[1]: apache2.service: Succeeded.
Mar 15 08:45:16 DietPi systemd[1]: Stopped The Apache HTTP Server.
Mar 15 08:45:16 DietPi systemd[1]: Starting The Apache HTTP Server...
Mar 15 08:45:17 DietPi systemd[1]: Started The Apache HTTP Server.
Mar 15 08:52:43 DietPi systemd[1]: Reloading The Apache HTTP Server.
Mar 15 08:52:43 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Mar 15 08:52:50 DietPi systemd[1]: Reloading The Apache HTTP Server.
Mar 15 08:52:50 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Mar 15 08:54:51 DietPi systemd[1]: Reloading The Apache HTTP Server.
Mar 15 08:54:51 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Mar 15 08:55:00 DietPi systemd[1]: Reloading The Apache HTTP Server.
Mar 15 08:55:00 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Mar 15 08:56:10 DietPi systemd[1]: Reloading The Apache HTTP Server.
Mar 15 08:56:10 DietPi systemd[1]: Reloaded The Apache HTTP Server.
Here's the apache2.conf, thought this might be useful.

Code: Select all

Mutex file:${APACHE_LOCK_DIR} default

PidFile ${APACHE_PID_FILE}

Timeout 60

KeepAlive On

MaxKeepAliveRequests 20

KeepAliveTimeout 5

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel error

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        DirectoryIndex index.php index.html
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

AccessFileName .htaccess

<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# Set Global ServerName
ServerName 127.0.0.1
bbkhdt
Posts: 9
Joined: Sun Mar 14, 2021 6:29 pm

Re: Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by bbkhdt »

Also with the files given above in place apachectl configtest now gives me Syntax OK :?
User avatar
MichaIng
Site Admin
Posts: 3105
Joined: Sat Nov 18, 2017 6:21 pm

Re: Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by MichaIng »

You changed the htaccess.RewriteBase in config.php, but did you also rebuild the .htaccess file? ncc maintanance:update:htaccess

Else, could you try to set the ServerName to the domain or IP address that you use to access the Nextcloud server? It should not play a role here, although I'm no exactly sure thow the .htaccess directives might indirectly use it, and generally Nextcloud then, e.g. to have the trusted domains list satisfied.

And if the above does not help, increase the logging level to LogLevel notice, at least temporarily to get more logs.
bbkhdt
Posts: 9
Joined: Sun Mar 14, 2021 6:29 pm

Re: Nextcloud Apache virtualhost and ocm-provider/ocs-provider redirect

Post by bbkhdt »

Hi!

ncc maintanance:update:htaccess gave me this output:

Code: Select all

An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No route to host in /var/www/nextcloud/lib/private/DB/Connection.php:85
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1486): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1014): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(226): Doctrine\DBAL\Connection->executeQuery('SELECT * FROM `...', Array, Array, NULL)
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(210): OC\DB\Connection->executeQuery('SELECT * FROM `...', Array, Array)
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(286): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(345): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(110): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(301): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(957): OC\AppConfig->getValues(false, 'installed_versi...')
#9 /var/www/nextcloud/lib/private/Server.php(678): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}(Object(OC\Server))
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet('OC\\Memcache\\Fac...')
#13 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Utility\SimpleContainer->query('OC\\Memcache\\Fac...', false)
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query('OC\\Memcache\\Fac...')
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(177): OC\AppFramework\Utility\SimpleContainer->get('OC\\Memcache\\Fac...')
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet('OCP\\ICacheFacto...')
#19 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Utility\SimpleContainer->query('OCP\\ICacheFacto...', false)
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query('OCP\\ICacheFacto...')
#21 /var/www/nextcloud/lib/private/Server.php(1018): OC\AppFramework\Utility\SimpleContainer->get('OCP\\ICacheFacto...')
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}(Object(OC\Server))
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet('OCP\\Lock\\ILocki...')
#25 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Utility\SimpleContainer->query('OCP\\Lock\\ILocki...', false)
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query('OCP\\Lock\\ILocki...')
#27 /var/www/nextcloud/lib/private/Server.php(1977): OC\AppFramework\Utility\SimpleContainer->get('OCP\\Lock\\ILocki...')
#28 /var/www/nextcloud/lib/private/Files/View.php(119): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(426): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}(Object(OC\Server))
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet('OC\\Files\\Node\\H...')
#33 /var/www/nextcloud/lib/private/ServerContainer.php(137): OC\AppFramework\Utility\SimpleContainer->query('OC\\Files\\Node\\H...', false)
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query('OC\\Files\\Node\\H...')
#35 /var/www/nextcloud/lib/private/Server.php(1340): OC\AppFramework\Utility\SimpleContainer->get('OC\\Files\\Node\\H...')
#36 /var/www/nextcloud/lib/base.php(588): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1076): OC::init()
#38 /var/www/nextcloud/console.php(49): require_once('/var/www/nextcl...')
#39 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
Post Reply