# Forcing https... Help?

**URL:** <https://help.nextcloud.com/t/forcing-https-help/57386>\
**Category:** 📦 Appliances (Docker, Snappy, VM, NCP, AIO)\
**Tags:** qnap\
**Created:** [July 29, 2019, 10:57am UTC](https://help.nextcloud.com/t/forcing-https-help/57386 "2019-07-29T10:57:33Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![deljones](https://help.nextcloud.com/user_avatar/help.nextcloud.com/deljones/32/11063_2.png) [@deljones](https://help.nextcloud.com/u/deljones)\
**Post date:** [July 29, 2019, 10:57am UTC](https://help.nextcloud.com/t/forcing-https-help/57386/1 "2019-07-29T10:57:33Z")

</div>

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. https://mydomain\_name.com. 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 mydomain\_name.com.

Many thanks for you time

DJones

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [July 29, 2019, 12:00pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/2 "2019-07-29T12:00:10Z")

</div>

If you are using [Apache2](https://docs.nextcloud.com/server/15/admin_manual/installation/harden_server.html#redirect-all-unencrypted-traffic-to-https):

```
<VirtualHost *:80>
    ServerName mydomain_name.com
    Redirect permanent / https://mydomain_name.com/
</VirtualHost>

```

If you are using [ngnix](https://docs.nextcloud.com/server/15/admin_manual/installation/nginx.html):

```
server {
listen 80;
listen [::]:80;
server_name mydomain_name.com;
# enforce https
return 301 https://$server_name:443$request_uri;
}
```

---

<div class="post-metadata">

**Author:** ![deljones](https://help.nextcloud.com/user_avatar/help.nextcloud.com/deljones/32/11063_2.png) [@deljones](https://help.nextcloud.com/u/deljones)\
**Post date:** [July 31, 2019, 2:47pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/3 "2019-07-31T14:47:37Z")

</div>

HI there…

Many thanks. I shall give this a try later…

Cheers

Dj

---

<div class="post-metadata">

**Author:** ![deljones](https://help.nextcloud.com/user_avatar/help.nextcloud.com/deljones/32/11063_2.png) [@deljones](https://help.nextcloud.com/u/deljones)\
**Post date:** [July 31, 2019, 3:04pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/4 "2019-07-31T15:04:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KarlF12](https://help.nextcloud.com/user_avatar/help.nextcloud.com/karlf12/32/46873_2.png) [@KarlF12](https://help.nextcloud.com/u/KarlF12)\
**Post date:** [July 31, 2019, 7:25pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/5 "2019-07-31T19:25:37Z")

</div>

They are additional virtual host configurations for the web servers.

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [August 1, 2019, 6:41am UTC](https://help.nextcloud.com/t/forcing-https-help/57386/6 "2019-08-01T06:41:28Z")

</div>

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

> [@Nextcloud (Mint/Apache) SSL on port 8888/443 not working](https://help.nextcloud.com/t/nextcloud-mint-apache-ssl-on-port-8888-443-not-working/49810/4):
>
> This is my LIVE config for NC

Here is how to enable http2 and strong encryption: [How to disable TLS 1.0 - #7 by gas85](https://help.nextcloud.com/t/how-to-disable-tls-1-0/54412/7)

---

<div class="post-metadata">

**Author:** ![deljones](https://help.nextcloud.com/user_avatar/help.nextcloud.com/deljones/32/11063_2.png) [@deljones](https://help.nextcloud.com/u/deljones)\
**Post date:** [August 2, 2019, 9:27am UTC](https://help.nextcloud.com/t/forcing-https-help/57386/7 "2019-08-02T09:27:05Z")

</div>

Hmmm. Yes. Once I asked the question I thought better to get off my ass and do some of my own homework 🙂 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 domain\_name.co.uk/8080. So I added this port to my enabled-sites, restarted the server but still no change… ☹

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

Dj

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [August 2, 2019, 9:39am UTC](https://help.nextcloud.com/t/forcing-https-help/57386/8 "2019-08-02T09:39:44Z")

</div>

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 - #10 by gas85](https://help.nextcloud.com/t/nextcloud-webroot-and-data-directory-best-practices-on-ubuntu-18-04-lts/54927/10)

> [@deljones](#):
>
> port number 8080

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:

> **[GitHub - nextcloud/docker: ⛴ Docker image of Nextcloud](https://github.com/nextcloud/docker#using-the-apache-image)**
>
> ⛴ Docker image of Nextcloud. Contribute to nextcloud/docker development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![deljones](https://help.nextcloud.com/user_avatar/help.nextcloud.com/deljones/32/11063_2.png) [@deljones](https://help.nextcloud.com/u/deljones)\
**Post date:** [August 2, 2019, 1:36pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/9 "2019-08-02T13:36:06Z")

</div>

gas85…

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\>  
ServerName [nextdesk.co.uk](http://nextdesk.co.uk)  
Redirect permanent / [https://nextdesk.co.uk](https://nextdesk.co.uk)

\<VirtualHost \*:8080\>  
ServerName [nextdesk.co.uk](http://nextdesk.co.uk)  
Redirect permanent / [https://nextdesk.co.uk](https://nextdesk.co.uk)

\<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

Dj

---

<div class="post-metadata">

**Author:** ![deljones](https://help.nextcloud.com/user_avatar/help.nextcloud.com/deljones/32/11063_2.png) [@deljones](https://help.nextcloud.com/u/deljones)\
**Post date:** [August 2, 2019, 1:52pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/10 "2019-08-02T13:52:04Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![KarlF12](https://help.nextcloud.com/user_avatar/help.nextcloud.com/karlf12/32/46873_2.png) [@KarlF12](https://help.nextcloud.com/u/KarlF12)\
**Post date:** [August 2, 2019, 3:25pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/11 "2019-08-02T15:25:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![deljones](https://help.nextcloud.com/user_avatar/help.nextcloud.com/deljones/32/11063_2.png) [@deljones](https://help.nextcloud.com/u/deljones)\
**Post date:** [August 3, 2019, 12:39am UTC](https://help.nextcloud.com/t/forcing-https-help/57386/12 "2019-08-03T00:39:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![enoch85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/enoch85/32/49403_2.png) [@enoch85](https://help.nextcloud.com/u/enoch85)\
**Post date:** [August 5, 2019, 6:57pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/13 "2019-08-05T18:57:22Z")

</div>

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:

> <https://github.com/nextcloud/vm/blob/master/lets-encrypt/activate-ssl.sh#L118-L121>

---

<div class="post-metadata">

**Author:** ![enoch85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/enoch85/32/49403_2.png) [@enoch85](https://help.nextcloud.com/u/enoch85)\
**Post date:** [August 5, 2019, 6:58pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/14 "2019-08-05T18:58:35Z")

</div>

Aah, now when I’m reading again I can see that you use a _non default_ port. 🙂

Glad it worked out for you!

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 4, 2024, 10:10am UTC](https://help.nextcloud.com/t/forcing-https-help/57386/15 "2024-12-04T10:10:47Z")

</div>



---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 11, 2024, 3:23pm UTC](https://help.nextcloud.com/t/forcing-https-help/57386/16 "2024-12-11T15:23:28Z")

</div>


