# Force gui to https

**URL:** <https://community.freepbx.org/t/force-gui-to-https/44303>\
**Category:** Configuration\
**Created:** [September 22, 2017, 11:51am UTC](https://community.freepbx.org/t/force-gui-to-https/44303 "2017-09-22T11:51:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![vespino](https://community.freepbx.org/letter_avatar_proxy/v4/letter/v/c4cdca/32.png) [@vespino](https://community.freepbx.org/u/vespino)\
**Post date:** [September 22, 2017, 11:51am UTC](https://community.freepbx.org/t/force-gui-to-https/44303/1 "2017-09-22T11:51:40Z")

</div>

I have installed a let’s encrypt certificate on my FreePBX, but how do I now redirect the gui to https without having to change either the PHP files or .htaccess? These both end up in a changed file error so I’m trying to keep away from that.

---

<div class="post-metadata">

**Author:** ![thehammer86](https://community.freepbx.org/letter_avatar_proxy/v4/letter/t/6a8cbe/32.png) [@thehammer86](https://community.freepbx.org/u/thehammer86)\
**Post date:** [September 22, 2017, 2:45pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/2 "2017-09-22T14:45:36Z")

</div>

I would like to see this as an option in the GUI as well. Auto redirect admin and ucp to https. Open a feature request and I’m sure others along with myself will upvote it.

---

<div class="post-metadata">

**Author:** ![vespino](https://community.freepbx.org/letter_avatar_proxy/v4/letter/v/c4cdca/32.png) [@vespino](https://community.freepbx.org/u/vespino)\
**Post date:** [September 22, 2017, 2:51pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/3 "2017-09-22T14:51:58Z")

</div>

So what you are saying is that it’s not possible at this moment? Then why implement Let’s Encrypt in the first place?

---

<div class="post-metadata">

**Author:** ![Marbled](https://community.freepbx.org/user_avatar/community.freepbx.org/marbled/32/8198_2.png) [@Marbled](https://community.freepbx.org/u/Marbled)\
**Post date:** [September 22, 2017, 2:53pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/4 "2017-09-22T14:53:03Z")

</div>

Hi!

It would be a looooooot nicer to be able to do this without the need to hack Apache’s HTTP server config but this is what is done on a server we have at work.

> \<VirtualHost \*:80\>  
> RewriteEngine on
> 
> RewriteCond %{HTTPS} off  
> RewriteRule ^/(.\*) https://%{HTTP\_HOST}%{REQUEST\_URI} [NC,R=301,NE,L]

The virtual host which handles HTTP traffic unilaterally redirect everything to the same URL but in HTTPS…

Good luck and have a nice day!

Nick

---

<div class="post-metadata">

**Author:** ![billsimon](https://community.freepbx.org/user_avatar/community.freepbx.org/billsimon/32/8369_2.png) [@billsimon](https://community.freepbx.org/u/billsimon)\
**Post date:** [September 22, 2017, 2:58pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/5 "2017-09-22T14:58:07Z")

</div>

Why do you need a redirect? If you don’t want plain HTTP traffic, block port 80 with the firewall.

---

<div class="post-metadata">

**Author:** ![vespino](https://community.freepbx.org/letter_avatar_proxy/v4/letter/v/c4cdca/32.png) [@vespino](https://community.freepbx.org/u/vespino)\
**Post date:** [September 22, 2017, 3:00pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/6 "2017-09-22T15:00:27Z")

</div>

Yes that is what I would have come up with too, but I only want the gui on https. The main directory contains a couple of files that need to be http. For example: I have a script the creates an XML file which my phones import. Apparently my phones have problems importing from https. So that is why…

---

<div class="post-metadata">

**Author:** ![vespino](https://community.freepbx.org/letter_avatar_proxy/v4/letter/v/c4cdca/32.png) [@vespino](https://community.freepbx.org/u/vespino)\
**Post date:** [September 22, 2017, 3:01pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/7 "2017-09-22T15:01:26Z")

</div>

Because it’s easier?

---

<div class="post-metadata">

**Author:** ![Marbled](https://community.freepbx.org/user_avatar/community.freepbx.org/marbled/32/8198_2.png) [@Marbled](https://community.freepbx.org/u/Marbled)\
**Post date:** [September 22, 2017, 3:02pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/8 "2017-09-22T15:02:44Z")

</div>

Hi!

> [@billsimon](#):
>
> Why do you need a redirect? If you don’t want plain HTTP traffic, block port 80 with the firewall.

I believe he wants that to be done transparently, this was a requirement at my work as well…

Have a nice day!

Nick

---

<div class="post-metadata">

**Author:** ![billsimon](https://community.freepbx.org/user_avatar/community.freepbx.org/billsimon/32/8369_2.png) [@billsimon](https://community.freepbx.org/u/billsimon)\
**Post date:** [September 22, 2017, 3:09pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/9 "2017-09-22T15:09:41Z")

</div>

> [@Marbled](#):
>
> RewriteRule ^/(.\*) https://%{HTTP\_HOST}%{REQUEST\_URI} [NC,R=301,NE,L]

change the regex to ^/admin.\* which is where the FreePBX GUI is.

---

<div class="post-metadata">

**Author:** ![thehammer86](https://community.freepbx.org/letter_avatar_proxy/v4/letter/t/6a8cbe/32.png) [@thehammer86](https://community.freepbx.org/u/thehammer86)\
**Post date:** [September 22, 2017, 10:48pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/10 "2017-09-22T22:48:53Z")

</div>

> [@billsimon](#):
>
> Why do you need a redirect? If you don’t want plain HTTP traffic, block port 80 with the firewall.

End users don’t care to type in http:// let’s alone https:// too.

All they need to remember is [pbx.domain.com](http://pbx.domain.com) and the server will auto redirect just like when you type in google.ca and it automatically goes to [https://www.google.ca](https://www.google.ca)

I think the reason we are asking for FreePBX devs to add an option is that we may not want all http requests redirected to https. Provisioning of non-sangoma endpoints is only available over http but an admin may want to make UCP for end users selectively available over https.

---

<div class="post-metadata">

**Author:** ![vespino](https://community.freepbx.org/letter_avatar_proxy/v4/letter/v/c4cdca/32.png) [@vespino](https://community.freepbx.org/u/vespino)\
**Post date:** [September 25, 2017, 7:59am UTC](https://community.freepbx.org/t/force-gui-to-https/44303/11 "2017-09-25T07:59:45Z")

</div>

I added the following to /etc/httpd/conf.d/freepbx.conf :

```
<VirtualHost *:80>
 RewriteEngine on
 RewriteCond %{HTTPS} !=on [NC]
 RewriteRule ^/admin(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>

```

service httpd restart =\> go!

Now I hope somebody from FreePBX is reading this and will implement an easier way using the GUI.

---

<div class="post-metadata">

**Author:** ![jervin](https://community.freepbx.org/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@jervin](https://community.freepbx.org/u/jervin)\
**Post date:** [July 10, 2018, 1:07pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/12 "2018-07-10T13:07:01Z")

</div>

Won’t blocking http port 80 keep the system from renewing the Letsencrypt certificate after 90 days. I think Letsencrypt requires use of port 80.

---

<div class="post-metadata">

**Author:** ![dicko](https://community.freepbx.org/user_avatar/community.freepbx.org/dicko/32/8712_2.png) [@dicko](https://community.freepbx.org/u/dicko)\
**Post date:** [July 10, 2018, 1:33pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/13 "2018-07-10T13:33:50Z")

</div>

Not really, letsencrypt just tests for connectivity on port 80 at the ip address your domain name resolves to. It doesn’t test what is returned

---

<div class="post-metadata">

**Author:** ![jervin](https://community.freepbx.org/letter_avatar_proxy/v4/letter/j/a183cd/32.png) [@jervin](https://community.freepbx.org/u/jervin)\
**Post date:** [July 10, 2018, 4:40pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/14 "2018-07-10T16:40:47Z")

</div>

Some of the suggestions above were to block port 80 at the firewall.

When I changed my http port to something other than 80 in System Admin Pro, Letsencrypt would not renew itself. This was in Freepbx version 13. So I was assuming that if you block 80 in the firewall on your router or on Freepbx, you’d have similar results.

---

<div class="post-metadata">

**Author:** ![dicko](https://community.freepbx.org/user_avatar/community.freepbx.org/dicko/32/8712_2.png) [@dicko](https://community.freepbx.org/u/dicko)\
**Post date:** [July 10, 2018, 5:48pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/15 "2018-07-10T17:48:15Z")

</div>

I’d you block 80, then you can’t rewrite it, I was responding to that post.

---

<div class="post-metadata">

**Author:** ![JeremiahBarkman](https://community.freepbx.org/user_avatar/community.freepbx.org/jeremiahbarkman/32/14238_2.png) [@JeremiahBarkman](https://community.freepbx.org/u/JeremiahBarkman)\
**Post date:** [October 18, 2018, 5:23pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/16 "2018-10-18T17:23:05Z")

</div>

Hi Bill,😃

I am dealing with this right now. I looked up this issue because if I don’t block port 80 then users can access the UCP or /admin unsecured out of laziness or ignorance. If I block port 80 then they get a 404. So I wan’t to redirect to keep things easy and secure. Am I missing your point?

---

<div class="post-metadata">

**Author:** ![billsimon](https://community.freepbx.org/user_avatar/community.freepbx.org/billsimon/32/8369_2.png) [@billsimon](https://community.freepbx.org/u/billsimon)\
**Post date:** [October 18, 2018, 5:56pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/17 "2018-10-18T17:56:03Z")

</div>

Technically if you block port 80 and they go for the http site they should not get a “404” but some sort of browser-side error saying the host could not be reached.

In the year+ since this topic was posted I have noticed something. Browsers now seem to be defaulting to https if you just type in a URL without the scheme part. So that’s interesting, but I don’t think it’s everywhere / every browser yet so you can’t count on it to serve the lazy user.

To redirect the plain http requests you should use vespino’s answer at [Force gui to https](https://community.freepbx.org/t/force-gui-to-https/44303/10)

To make sure the users get redirected when they go to /ucp then change the RewriteRule to be `^/(.*)$` instead of `^/admin(.*)$` . I think that should work fine.

Good to see you here friend! 🙂

---

<div class="post-metadata">

**Author:** ![JeremiahBarkman](https://community.freepbx.org/user_avatar/community.freepbx.org/jeremiahbarkman/32/14238_2.png) [@JeremiahBarkman](https://community.freepbx.org/u/JeremiahBarkman)\
**Post date:** [October 18, 2018, 9:17pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/18 "2018-10-18T21:17:03Z")

</div>

Hi Bill,

You are correct. It was not a 404. I misspoke. I will use the recommended redirect. Thanks for the reply. I hope you are doing well. 🙂

---

<div class="post-metadata">

**Author:** ![volkswagner](https://community.freepbx.org/letter_avatar_proxy/v4/letter/v/94ad74/32.png) [@volkswagner](https://community.freepbx.org/u/volkswagner)\
**Post date:** [August 10, 2019, 10:22pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/19 "2019-08-10T22:22:21Z")

</div>

I’m looking into helping the lazy as well… self included.  
Perhaps multiple subdomains would be helpful to segregate things like  
access areas that phones need for scripts/configs that need to be on port 80.

I think a feature request for adding SANs to the let’s encrypt module would help.  
Subject Alternate Name (or **SAN** ) **certificate**  
This way we could set aside a few domains/subdomains for the purpose of UCP, admin, and other port 80 stuff.

Otherwise we can manually run ACME and edit http files for multiple domains/subdomains to  
get the desire results.

---

<div class="post-metadata">

**Author:** ![system](https://community.freepbx.org/uploads/default/original/3X/f/7/f7056d57e04fdbf71c6ad967e1ced351317f5c3f.png) [@system](https://community.freepbx.org/u/system)\
**Post date:** [September 10, 2019, 10:22pm UTC](https://community.freepbx.org/t/force-gui-to-https/44303/20 "2019-09-10T22:22:25Z")

</div>

Closed on September 10, 2019, 10:22pm UTC

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
