Nextcloud Apache2 configuration

Nextcloud Apache2 configuration

Here is an example configuration file to use Nextcloud with an Apache2 server in Ubuntu. Here, it is assumed that nextcloud install is located in /var/www/

<VirtualHost *:80>
	# Redirection to HTTPS
	ServerName nextcloud.example.com
	Redirect / https://nextcloud.example.com/
</VirtualHost>

<IfModule mod_ssl.c>
	<VirtualHost *:443>

	ServerName nextcloud.example.com

	DocumentRoot /var/www/nextcloud/

	# Specific configuration for nextcloud
	<Directory /var/www/nextcloud/>
		Options +FollowSymlinks
		AllowOverride All

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

		SetEnv HOME /var/www/nextcloud
		SetEnv HTTP_HOME /var/www/nextcloud

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

	# SSL configuration
	SSLEngine on
	SSLCertificateFile /etc/letsencrypt/live/nextcloud.example.com/fullchain.pem
	SSLCertificateKeyFile /etc/letsencrypt/live/nextcloud.example.com/privkey.pem

	</VirtualHost>
</IfModule>