Forcing https... Help?

Hi all…

I have installed the Tech and Me Nextcloud VM which is up and running and everything works including SSL with letsencrypt. However. I have to type the whole thing in a new browser. If I just type in the address without the https it won’t work and times out. Is there a way I can force https when typing in the just the address

Many thanks for you time


If you are using Apache2:

<VirtualHost *:80>
    Redirect permanent /

If you are using ngnix:

server {
listen 80;
listen [::]:80;
# enforce https
return 301 https://$server_name:443$request_uri;
1 Like

HI there…

Many thanks. I shall give this a try later…



Hi gas85. These lines of tex, are they an additional lines or will i find them to edit?

They are additional virtual host configurations for the web servers.

1 Like

You can see full examples under linked Doku from nextcloud, also I post ones my NC Apache2 config in this forum:

Here is how to enable http2 and strong encryption: How to disable TLS 1.0

Hmmm. Yes. Once I asked the question I thought better to get off my ass and do some of my own homework :slight_smile: I found the files and location where the virtual site info is kept. enabled-sites and available-sites. I did the edit there by adding the word “permanent”, which was missing but that didn’t work. What I found is that if I left the browser long enough to time out then my domain name would be appended with port number 8080, so So I added this port to my enabled-sites, restarted the server but still no change… :frowning:

I know I’m missing something or doing something stupid!!


You need to restart the Server after you made changes:

sudo service apache2 restart

Before to do it, you can check your configuration by command:

sudo apachectl configtest

I made few comments here: Nextcloud webroot and data directory - best practices on Ubuntu 18.04 LTS

It seems you have a Docker installation, for this you need to set port forwarding for your nextcloud container in Docker. Command depends on exact Image being used:

docker run -d -p 8080:80 nextcloud

Read more about:


Thanks for your help so far. It does make me go away and read up stuff so I’m grateful for the advice etc. I’m learning!
It’s not quite a docker it’s QNAP virtualization station. The port 8080 is used for accessing the NAS web interface. I tried to change the port number from 8080 to 8585 but the result was the same, of course it would be, I realised that later. if I use a cleared browser and insert the address with out any http protocol it times out with just the address and :8585 appended at the end.

I have also restarted the server everytime I change the apache file.

<VirtualHost *:80>
Redirect permanent /

<VirtualHost *:8080>
Redirect permanent /

<VirtualHost *:443>

I’m guessing that I dont really need the 8080 port as a vHost

Thanks for you help and advise… More reading I feel


The QNAP NAS has this Network and virtual switch app… My guess is that the issue will be in there somewhere. Ive notice that the VM with my nextcloud instance is not on its own virtual switch…? Maybe?

When I set up certbot on my Apache reverse proxy, it set up forcing HTTPS for me. It used a rewrite instead of a redirect, but either should work. Technically speaking, I believe redirect is supposed to be the “official” mechanism for doing this.

I run the reverse proxy on the host OS running Docker.

Hi gas85… Working!!!

Thanks to your pointers, some reading, trial and error etc, https only is working!! The QNAP NAS has this app called Networking and Virtual Switch. I have two NICs in my NAS which where trunked together. If you run a virtual machine, which my nextcloud instance is, then you have to separate the NICs and create a virtual switch for the VM whci si then routed to the physical adapter. So all good. Played with the Virtual Hosts file to check what happens with different settings in that file, just to learn what goes on and how it works. Good learning was had…

Thanks very much

Dj x


Hmm, this seems like a bug. It should already redirect properly if you used the default configs that are created when you set it up.

Check here:

Aah, now when I’m reading again I can see that you use a non default port. :slight_smile:

Glad it worked out for you!

1 Like