Internal server error when using domain name

Hi everyone!

I had to reinstall my Nextcloud application but I am struggling at the last step!

I created a docker compose with customized folders for data, html and database. The goal eventually is mainly to have a folder data on another partition of my server
Please find the docker-compose below.

The application is running perfectly as long as I stay in local. When I call the IP:8085, no problem I can navigate through the application.

I then tried to configure apache to make it available online. This is where I have an issue.
I followed the documentation in order to configure apacheand activate the reauired modules.
I also used cerbot to generate and implement the ssl certificate zith the command sudo certbot --apache.
I put the :80 and :443 .conf files below.

My problem is that when I try to access nextcloud using the domain name, I reach the Internal server error page even though the application is well running.
I couldn’t find anything neither in the Apache’s error and access logs, nor in the nextcloud.log.

I’m pretty sure there is an issue with rights or links between nextcloud folders and apache directoriees but I couldn’t find any relevant information about it so far…

Thank you for your help on this!!

The docker-compose file:

version: '3.8'

services:
#######################################
##########     NEXTCLOUD     ##########
#######################################
  nextcloud-db-test:
    image: postgres:alpine
    container_name: nextcloud-db-test
    restart: always
    volumes:
      - /docker/Nextcloud2/database:/var/lib/postgresql/data
    env_file:
      - .nextcloud_db.env

  nextcloud-redis-test:
    image: redis:alpine
    container_name: nextcloud-redis-test
    restart: always

  nextcloud_cron-test:
    image: nextcloud
    container_name: nextcloud-cron-test
    restart: always
    volumes:
      - /docker/Nextcloud2/html:/var/www/html
    entrypoint: /cron.sh
    depends_on:
       - nextcloud-db-test
       - nextcloud-app-test

  nextcloud-app-test:
    image: nextcloud:latest
    container_name: nextcloud-app-test
    restart: always
    volumes:
      - /docker/Nextcloud2/html:/var/www/html
      - /docker/Nextcloud2/data:/var/www/html/data
    ports:
      - 8085:80
    environment:
      - POSTGRES_HOST=nextcloud-db-test
      - REDIS_HOST=nextcloud-redis-test
      - NEXTCLOUD_TRUSTED_DOMAINS=mydomain.example.com
      - VIRTUAL_HOST=mydomain.example.com
    env_file:
      - .nextcloud_db.env
    depends_on:
      - nextcloud-db-test
      - nextcloud-redis-test

The Nextcloud.conf file (for :80 requests)

<VirtualHost *:80>
        ServerName mydomain.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /docker/Nextcloud2/html

        ErrorLog ${APACHE_LOG_DIR}/Nextcloud-test-error.log
        CustomLog ${APACHE_LOG_DIR}/Nextcloud-test-access.log combined

       <Directory /docker/Nextcloud2/html>
                Require all granted
                AllowOverride All
                Options FollowSymLinks MultiViews
                <IfModule mod_dav.c>
                        Dav off
                </IfModule>
        </Directory>

        RewriteEngine on
        RewriteCond %{SERVER_NAME} =volka-test.hkl.ovh
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

The Nextcloud-ssl.conf file (for https requests)

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName mydomain.example.com

        <IfModule mod_headers.c>
                Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
        </IfModule>

        ServerAdmin mail@example.com
        DocumentRoot /docker/Nextcloud2/html

        ErrorLog ${APACHE_LOG_DIR}/Nextcloud-test-error.log
        CustomLog ${APACHE_LOG_DIR}/Nextcloud-test-access.log combined

       <Directory /docker/Nextcloud2/html>
                Require all granted
                AllowOverride All
                Options FollowSymLinks MultiViews
                <IfModule mod_dav.c>
                        Dav off
                </IfModule>
        </Directory>

        SSLCertificateFile /etc/letsencrypt/live/mydomain.example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.example.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

welcome to the forum @BGrard :handshake:

if I get you right you are editing Apache config files within container? if yes please stop doing so - the idea of container is they remain unchanged and required config is passed vie config from outside… For Nextcloud you better setup external reverse proxy Apahce/Nginx/traefic/Caddy whatever is works for you and configure this reverse proxy to terminate TLS and pass plan http: to the service behind it.

Fiddling with Apache within NC container fails latest at the point when you setup high-performance-backend for files (notify_push), which is separate container running on the same host but different path…

published ports don’t really make sense as well… you forward the port 8085 on the host into port 80 of your container… Maybe I don’t get you infrastructure right, in this case please describe with more details.

Please review official reverse proxy docs it might help you to setup reverse proxy in front of you container:

https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/reverse_proxy_configuration.html

Hi @wwe and thank you for your quick answer!

First to answer your questions:

  • I don’t try to setup anything inside the dockers. That is the reason why I set up the volumes on physical folders. So I can modify the config files outside of the docker.
  • I juste opened a port to control that the application is running and accessible from the local network.
  • The .conf files are from apache on my server. I use Apache as a reverse proxy and the .conf files above show how I set things up so far.

I’ve read the nextcloud documentation before contacting you guys. I really thought I could solve this issue alone considering the amount of information there is!

I tried to add again the php config recommended in your link, but same result.

Basically here I think the way I configured my Apache as reverse proxy is not entirely right…

for me it definitely sounds as you tamper with the config file of the docker image… don’t you?

take a look at this article it describes Nextcloud Apache Docker image config in fair detail

working apache reverse proxy config (e.g. I don’t see ProxyPassand ProxyPassReverse in your config):

and others Setup Apache reverse proxy with VM

search the forum and read the topics… you’ definitely find a solution.

Hi!

Thank you again for the time spent on my issue.

After reading your message and the documentation from the shared links, I thought that I should review the way I configured apache as reverse proxy.

Eventually I found that the following lines defining ProxyPass and ProxyPass Reverse were mandatory.
I had tried it earlier but I did not entered the right IP adress.

Here is the .conf file that made it worked:

<VirtualHost *:80>
        ProxyPreserveHost On

        ProxyPass / http://0.0.0.0:8080/
        ProxyPassReverse / http://0.0.0.0:8080/

        ServerName my.domain.com
        ServerAlias www.my.domain.com

        ServerAdmin webmaster@localhost
        DocumentRoot /docker/nextcloud/html

        ErrorLog ${APACHE_LOG_DIR}/nextcloud--error.log
        CustomLog ${APACHE_LOG_DIR}/nextcloud-access.log combined

       <Directory /docker/nextcloud/html>
                Require all granted
                AllowOverride All
                Options FollowSymLinks MultiViews
                <IfModule mod_dav.c>
                        Dav off
                </IfModule>
        </Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.my.domain.com [OR]
RewriteCond %{SERVER_NAME} =my.domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
1 Like