Struggling To Get HTTPS Redirect To Work Properly On ownCloud 10.0.8 Using Apache 2.4.29

Hello everyone

I setup an https redirect in owncloud.conf under /etc/apache2/sites-available, enabled it and restarted apache. The https redirect works but only if I disable both: 000-default.conf & default-ssl.conf and type http://owncloud.jam.lan/owncloud in my web browser. This leads me to believe I have set something up wrong.

Enabling 000-default.conf and default-ssl.conf and typing: owncloud.jam.lan into my web browser I get the: “It Works! Apache2 Ubuntu Default Page” If I type: owncloud.jam.lan/owncloud into my web browser then I get:

Not Found
The requested URL /owncloud was not found on this server.

Apache/2.4.29 (Ubuntu) Server at owncloud.jam.lan Port 443

Disabling both: 000-default.conf and default-ssl.conf allows me to access ownCloud. Going to owncloud.jam.lan I can access ownCloud but via http which is unacceptable as I do not want anyone accessing ownCloud via http.
But going to: owncloud.jam.lan/owncloud I am then redirected to https (even if I type http://owncloud.jam.lan/owncloud in my web browser). I’ve looked through the Apache manual and tried several of the examples they give but no luck and right now I’m just not understanding all the Apache directives, their hierarchy and how Apache “actually” interprets them. I would also like to keep the: “Redirect permanent” directive as the Apache manual says the: “mod_rewrite should be considered a last resort”. Any help would be greatly appreciated!

/etc/sites-available/owncloud.conf:

<VirtualHost *:80>
Alias /owncloud "/var/www/owncloud/"
ServerName http://owncloud.jam.lan/owncloud
DocumentRoot /var/www/owncloud
Redirect permanent /owncloud https://owncloud.jam.lan/owncloud
</VirtualHost>

<VirtualHost _default_:443>
Alias /owncloud "/var/www/owncloud"
ServerName https://owncloud.jam.lan/owncloud
DocumentRoot /var/www/owncloud
SSLEngine On
SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>

Hey,

i don’t think that the ServerName you’re currently using is correct. Maybe you can get more help on such Apache related questions / topics on a Apache support as well?

Hey Tom,

Thanks for the advice! Just curious, are you thinking the ServerName should be an IP address or something else?

Maybe you can have a look at some examples (e.g. in the Apache docs) how the ServerName should look like?

I see that the ServerName field appears to be a FQDN in the Apache docs but I have not purchased a domain for my owncloud setup so it is only accessible (as of right now) on my LAN. If that’s what this issue boils down to then I will purchase a domain but I want to make sure that is the problem before moving forward.