Change default landing page Apache2 to Nextcloud

Hello everyone!

I recently installed Nextcloud on my Raspberry PI 4B (4GB RAM version, DietPi version 9.6.1, Apache version 2.4.61), registered for a DNS domain, got a LetsEncrypt certificate for it and installed it. And just when I thought I finally got my Nextcloud instance to work under HTTPS…it didn’t. Whenever I type in my domain name, I face a default 'It works!" Apache site. This website uses SSL certificate and is viewed as safe by Firefox. To get to Nextcloud, I need to type “mydomainname/nextcloud” into the search bar. Here I get security warning as I try to log in that ‘my passwords, sensitive information etc.’ may be compromised, and the FIrefox shows that graphical sign with a lock crossed with a red line, saying how the site is not secured. How do I make it so that “mydomainname” shows Nextcloud and not the default apache website?

Thank you all in advance!

It would be helpful to post here your current apache.conf
However what you are most likely missing is a virtual server stanza to declare that the my.domain.name is using the document root for the nextcloud folder.

Hi trendy,
thank you for reaching out.

Here is my apache2.conf file located at /etc/apache2

# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
#       /etc/apache2/
#       |-- apache2.conf
#       |       `--  ports.conf
#       |-- mods-enabled
#       |       |-- *.load
#       |       `-- *.conf
#       |-- conf-enabled
#       |       `-- *.conf
#       `-- sites-enabled
#               `-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
#
# * ports.conf is always included from the main configuration file. It is   GNU nano 7.2                                                                   apache2.conf                                                                            
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
  GNU nano 7.2                                                                   apache2.conf                                                                            
#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

#
# The directory where shm and other runtime files will be stored.
#

DefaultRuntimeDir ${APACHE_RUN_DIR}

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
  GNU nano 7.2                                                                   apache2.conf                                                                            
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#

  GNU nano 7.2                                                                   apache2.conf                                                                            
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

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


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

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

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

#<Directory /srv/>
#       Options Indexes FollowSymLinks
#       AllowOverride None
#       Require all granted
                                                                         
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>

                                                                      
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>


#
                                                                 
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>


#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
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 of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

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

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

P.S. I hope I copy-pasted everything correctly fromthe terminal.
And I also remember I edited 000-default_pages.conf or something similar for VirtualHost…is that where I have to edit DocumentRoot? What do I have to type in for Nextcloud? Best regards

Isn’t it rather the file /etc/apache2/conf-enabled/dietpi.conf and then the entry
DocumentRoot /var/www
which needs to be changed to
DocumentRoot /var/www/nextcloud

If yes, what needs to be done afterwards to enable it? a2enmod ...?

1 Like

Hi StephanSts,

so I edited the file at the directory you mentioned, restarted apache2. The domain now points to Nextcloud but now I get the warning that ‘only HTTP is available, proceed with caution’ and when I click continue, I get this error in my browser:

" Internal Server Error

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.

More information about this error may be available in the server error log."

The title of the error is ‘500 Internal Server Error’
What do I do now?

This is the error found in the error log upon trying to connect to Nextcloud:

Jul 26 00:25:14 DietPi apache2[14554]:
[core:error] [pid 14554:tid 14635] [client 192.16
8.0.187:39364] AH00124: Request exceeded the limit of 10
 internal redirects due to probable configuration error.
 Use 'LimitInternalRecursion' to increase the limit if n
ecessary. Use 'LogLevel debug' to get a backtrace.

It would make sense to fix the SSL certificate problem before you play with a different configuration. Because it should make no difference whether you use my-domain.com or my-domain.com/nextcloud as the same certificate should be used. It doesn’t matter which sub-patch you use because the certificate is issued for the domain itself.

It only makes a difference if you use a subdomain like my-domain.com vs nextcloud.my-domain.com.

Okay, so I re-installed my certificate and now it reports mydomain.com/login (Nextcloud’s login page) as safe, except I still get that “500 Internal Server Error” so maybe my problem isn’t SSL but Apache? Because this error gives the output I wrote about in my last answer.

Can you share following

dietpi-services status

Sure! Here is the output of the command:

 DietPi-Services
─────────────────────────────────────────────────────
 Mode: status 

[  OK  ] DietPi-Services | redis-server		active (running) since Fri 2024-07-26 00:38:30 CEST; 2 days ago
[  OK  ] DietPi-Services | mariadb		active (running) since Fri 2024-07-26 00:38:30 CEST; 2 days ago
[  OK  ] DietPi-Services | php8.2-fpm		active (running) since Fri 2024-07-26 00:38:31 CEST; 2 days ago
[  OK  ] DietPi-Services | apache2		active (running) since Fri 2024-07-26 00:38:31 CEST; 2 days ago
[  OK  ] DietPi-Services | cron			active (running) since Fri 2024-07-26 00:38:31 CEST; 2 days ago
[  OK  ] DietPi-Services | ssh			active (running) since Fri 2024-07-26 00:21:37 CEST; 2 days ago
[ INFO ] DietPi-Services | dietpi-vpn		inactive (dead)
[  OK  ] DietPi-Services | fail2ban		active (running) since Fri 2024-07-26 00:38:22 CEST; 2 days ago
[ INFO ] DietPi-Services | dietpi-cloudshell	inactive (dead)
[  OK  ] DietPi-Services | dietpi-ramlog	active (exited) since Thu 2024-07-25 00:46:55 CEST; 3 days ago
[  OK  ] DietPi-Services | dietpi-preboot	active (exited) since Thu 2024-07-25 00:46:55 CEST; 3 days ago
[  OK  ] DietPi-Services | dietpi-postboot	active (exited) since Thu 2024-07-25 00:47:56 CEST; 3 days ago
[ INFO ] DietPi-Services | dietpi-wifi-monitor	inactive (dead)

that’s all good, are you able to access your Nextcloud using local network IP address?

I typed in DietPi IP address and I am yet again faced with “500 Internal Server Error.”
P.S. The IP address immediately re-routes me to Nextcloud’s login page (so unfortunately, I cannot access my Nextcloud with IP address nor DNS domain), as I changed the default site in DocumentRoot.

revert all changes you did to get original configuration back working. This way we could start from the beginning to fix SSL first.

1 Like

Hi!
I reverted all the changes, i.e. I changed the value of DocumentRoot at path /etc/apache2/conf-enabled/dietpi.conf from DocumentRoot /var/www/nextcloud to DocumentRoot /var/www. I restarted all the services and now both the mydomain (default apache2 site) and mydomain/nextcloud are viewed as safe. Right now I’m logged into Nextcloud and configuring some stuff but all in all, it works. At least for now xD
Thank you all so much!
'Til next time.

Theoretically you can create a simple redirect to get automatically forward from mydomain to mydomain/nextcloud. This way you don’t need to adjust DocumentRoot.

  • cd /etc/apache2/conf-available
  • nano redirect.conf
  • add following: RedirectMatch ^/$ /nextcloud/
  • save & exit
  • a2enconf redirect
  • systemctl reload apache2
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.