I have Nextcloud setup on a LAMP server on Ubuntu 16.04 Server. I am using Let’s Encrypt as my CA and initiated my cert with their certbot tool. I set it to force a redirect to a secure HTTPS connection, however it won’t establish an HTTPS connection unless I specify HTTPS. In my apache config files for VirtualHost *:80 I set rewrite conditions that worked for me before on Raspbian along with the lets encrypt certs. Here’s what’s in my nextcloud.conf file in /etc/apache2/sites-available (and symlinked to sites-enabled)
ReWriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
ReWriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
I’m just using the NC flags because that’s what I have been seeing everywhere, honestly I know very little about configuring Apache, I’m very new to web hosting
I tried the redirect statement once before and that didn’t work, what ended up working on my Pi at least was the ReWriteEngine and the other 2 lines. I will try what you sent though, I forgot about that
Thank you for sharing the link! So here is what I have found from installing this on Raspbian and Ubuntu 16.04 Server:
The redirect is working like I want it to work with the 3 lines I showed above on my Pi, however on Ubuntu Server I didn’t add those 3 lines, instead I did this:
That’s not cutting it for me either…I saw what Let’s Encrypt added to my conf file
RewriteEngine on
RewriteCond %{SERVER_NAME} =htnextcloud.duckdns.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
I followed your instructions and commented those out too with no luck. My other computer that is running nextcloud right now just has those 3 lines and it’s doing fine
Found it! It’s a networking problem. I could have sworn I port forwarded port 80 on my router but I guess it didn’t stick? Not sure why the config on my router didn’t save, but both of your answers work. I did what JasonBayton said and I don’t have any issues, I commented the RewriteEngine lines I showed in my comments