# How to disable direct https://ipaddress visit?

**URL:** https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927
**Category:** Self-hosting
**Tags:** tablet
**Created:** [September 9, 2016, 10:06am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927 "2016-09-09T10:06:20Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [September 9, 2016, 10:06am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/1 "2016-09-09T10:06:20Z")

</div>

see title.  
How to prohibit [https://ipaddress](https://ipaddress) visit the website or using [http://ip:443](http://ip:443)?  
How to configure in the docker nginx?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [September 9, 2016, 11:57am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/2 "2016-09-09T11:57:04Z")

</div>

I can’t answer how, but I want to ask _why?_

---

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [September 9, 2016, 12:52pm UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/3 "2016-09-09T12:52:32Z")

</div>

the reason is let all traffic go through the name server. you can only just visit from the domain name.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [September 9, 2016, 2:34pm UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/4 "2016-09-09T14:34:40Z")

</div>

Step 1: get a valid certificate for your IP address.

---

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [September 9, 2016, 4:27pm UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/5 "2016-09-09T16:27:14Z")

</div>

ssl was installed. [https://mydomain.com](https://mydomain.com) can be visited. but [https://myip](https://myip) can also be visited with the warning of certification. how to prohibit ip visition？

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [September 9, 2016, 4:28pm UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/6 "2016-09-09T16:28:55Z")

</div>

Did you try this?

> <https://stackoverflow.com/questions/29104943/how-to-disable-direct-access-to-a-web-site-by-ip-address>

---

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [September 9, 2016, 4:42pm UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/7 "2016-09-09T16:42:34Z")

</div>

yes，you got my point. what i mean is how to set up in discourse docker nginx，need rebuild？

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [September 9, 2016, 4:46pm UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/8 "2016-09-09T16:46:03Z")

</div>

Modifing nginx conf inside the container is done trough the app.yml file.

For an example, see [here](https://meta.discourse.org/t/how-to-add-a-custom-http-header-to-your-discourse/26439).

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [September 9, 2016, 10:42pm UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/9 "2016-09-09T22:42:49Z")

</div>

> [@doudou](#):
>
> but [https://myip](https://myip) can also be visited with the warning of certification

That’s why step 1 is:

> [@mpalmer](#):
>
> get a valid certificate **for your IP address**.

> [@Falco](#):
>
> Did you try this?

That won’t work on HTTPS sites, because all the redirection, hostname checking, etc happens _after_ the SSL negotiation is complete.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [September 9, 2016, 11:30pm UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/10 "2016-09-09T23:30:35Z")

</div>

Wait, they want to NOT let people visit with just the IP.

Which is a little odd - exactly what harm is this doing, @doudou?

---

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [September 10, 2016, 1:18am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/11 "2016-09-10T01:18:29Z")

</div>

just for prohibition. can this be done in system setting，like firewall？

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [September 10, 2016, 1:35am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/12 "2016-09-10T01:35:58Z")

</div>

You can’t do what you want to do using a firewall. In order to do what you want to achieve, you must first **get a valid, trusted certificate for your server’s IP address**. Until you have that, nothing else can be done. Talk to your preferred CA to organise that.

---

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [September 10, 2016, 2:09am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/13 "2016-09-10T02:09:24Z")

</div>

i just want when people visit the website via [https://serverip](https://serverip) he will get an internal 500 page or nothing at all and cant go on by clicking trust the certification. so i am seaching for the solution on nginx or firewall. any sugguestion？

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [September 10, 2016, 2:10am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/14 "2016-09-10T02:10:51Z")

</div>

It can’t be done unless you have a valid, trusted cert for your IP address. This is why I keep telling you to **get a valid, trusted certificate for your server’s IP address**.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [September 10, 2016, 3:30am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/15 "2016-09-10T03:30:51Z")

</div>

Nah, I think @doudou here would be happy if, after they clicked past the bad cert warning, _then_ they got the 500 page.

So a 99-year self-signed cert for the IP address would be fine.

One of many how-to guides for that: [http://www.cyberciti.biz/faq/nginx-self-signed-certificate-tutorial-on-centos-redhat-linux/](http://www.cyberciti.biz/faq/nginx-self-signed-certificate-tutorial-on-centos-redhat-linux/)

---

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [September 10, 2016, 4:06am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/16 "2016-09-10T04:06:34Z")

</div>

this could not be intergreted with domain name and with discourse using self sign and public CA

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [September 10, 2016, 6:48am UTC](https://meta.discourse.org/t/how-to-disable-direct-https-ipaddress-visit/49927/17 "2016-09-10T06:48:44Z")

</div>

With SNI, you can have multiple certificates. During the SSL negotiation the browser tells the server what name it is trying to reach, and the server returns the appropriate cert. The link I provided appeared to have instructions for SNI under nginx. Your regular site could use your regular cert.
