Forward HTTP to HTTPS

On various Hardware and OS systems: pi / windows / routers / nas, etc
Post Reply
beejee78
Posts: 7
Joined: Monday 11 April 2016 21:23
Target OS: Windows
Domoticz version:
Contact:

Forward HTTP to HTTPS

Post by beejee78 » Friday 27 October 2017 12:14

I've created a HTTPS certificate with letsencrypt for my domain now and it's working good when i connect to https://<my-domain>

But i always have to type https:// in front of my domain name. Is it possible to redirect to https automatically.
I searched everywhere but can't find an answer.

Thanx in advance!

BTW: Domoticz is running on an RPI.

gordonb3
Posts: 566
Joined: Friday 22 January 2016 11:15
Target OS: Linux
Domoticz version: custom
Location: The Netherlands
Contact:

Re: Forward HTTP to HTTPS

Post by gordonb3 » Friday 27 October 2017 12:43

Depends on what you have behind port 80. Most web servers will allow you to return a HTTP 301 (Moved permanently) that will make your browser follow the supplied link to the `new` location.
Excito B3 running Gentoo Linux, P1, Rfxtrx433 to read and control TFA, KaKu, EvoHome RFG100
Custom patched Domoticz v3.8000

beejee78
Posts: 7
Joined: Monday 11 April 2016 21:23
Target OS: Windows
Domoticz version:
Contact:

Re: Forward HTTP to HTTPS

Post by beejee78 » Friday 27 October 2017 13:40

Ok, but how do i do that?
There's nothing behind port 80 btw.

gordonb3
Posts: 566
Joined: Friday 22 January 2016 11:15
Target OS: Linux
Domoticz version: custom
Location: The Netherlands
Contact:

Re: Forward HTTP to HTTPS

Post by gordonb3 » Friday 27 October 2017 15:05

If there's nothing there than http won't work anyway.

You may want to try nginx. Then reference this page for how to make it return a 301.

Tip: do make use of named hosts. Create a server block entry for your domain that you want to redirect to https and one `catch all` default server that doesn't do anything (display an empty page, sample page or just a 404). The only people visiting your server without using the proper domain name are hackers and you do not want to give them any information what else you got running on it.
Excito B3 running Gentoo Linux, P1, Rfxtrx433 to read and control TFA, KaKu, EvoHome RFG100
Custom patched Domoticz v3.8000

beejee78
Posts: 7
Joined: Monday 11 April 2016 21:23
Target OS: Windows
Domoticz version:
Contact:

Re: Forward HTTP to HTTPS

Post by beejee78 » Friday 27 October 2017 15:25

Thanx!
Is all this not possible with the build-in webserver from Domoticz itself?

gordonb3
Posts: 566
Joined: Friday 22 January 2016 11:15
Target OS: Linux
Domoticz version: custom
Location: The Netherlands
Contact:

Re: Forward HTTP to HTTPS

Post by gordonb3 » Friday 27 October 2017 16:42

Not that I'm aware of. Besides it is a single purpose webserver that does not support vhosts and if you expose that to the outside world without any other type of hostname checking that will make you (more) vulnerable to script kiddies.
Excito B3 running Gentoo Linux, P1, Rfxtrx433 to read and control TFA, KaKu, EvoHome RFG100
Custom patched Domoticz v3.8000

Electrocut
Posts: 24
Joined: Sunday 04 May 2014 21:52
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Forward HTTP to HTTPS

Post by Electrocut » Friday 27 October 2017 16:55

Another option would be to add "HTTP Strict Transport Security" (HSTS) header to your web server.

With this header set, if you type http://domain in your address bar, your browser will automatically switch to https://domain, without even trying to contact the http://domain server.

beejee78
Posts: 7
Joined: Monday 11 April 2016 21:23
Target OS: Windows
Domoticz version:
Contact:

Re: Forward HTTP to HTTPS

Post by beejee78 » Monday 30 October 2017 9:16

Electrocut wrote:
Friday 27 October 2017 16:55
Another option would be to add "HTTP Strict Transport Security" (HSTS) header to your web server.

With this header set, if you type http://domain in your address bar, your browser will automatically switch to https://domain, without even trying to contact the http://domain server.
Sounds good. Is this possible in Domoticz?

User avatar
gizmocuz
Posts: 8526
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi
Domoticz version: beta
Location: Top of the world
Contact:

Re: Forward HTTP to HTTPS

Post by gizmocuz » Monday 30 October 2017 9:17

What you want to do could be done with NGINX as a proxy
Quality outlives Quantity!

beejee78
Posts: 7
Joined: Monday 11 April 2016 21:23
Target OS: Windows
Domoticz version:
Contact:

Re: Forward HTTP to HTTPS

Post by beejee78 » Monday 30 October 2017 10:24

Okay, I think I need NGINX at least. I will look at it, thank you!

essayreviews
Posts: 1
Joined: Thursday 09 November 2017 6:54
Target OS: Linux
Domoticz version:
Contact:

Re: Forward HTTP to HTTPS

Post by essayreviews » Thursday 09 November 2017 7:07

good post.how to covert the http to https.I need the https certificate,because the https is most valuable for site.how to convert that.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest