# Forcing access to Discourse via domain name only

**URL:** <https://meta.discourse.org/t/forcing-access-to-discourse-via-domain-name-only/70574>\
**Category:** Self-hosting\
**Created:** [22 Septiembre, 2017 13:39 UTC](https://meta.discourse.org/t/forcing-access-to-discourse-via-domain-name-only/70574 "2017-09-22T13:39:32Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Carlo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carlo/32/79036_2.png) [@Carlo](https://meta.discourse.org/u/Carlo)\
**Post date:** [22 Septiembre, 2017 13:39 UTC](https://meta.discourse.org/t/forcing-access-to-discourse-via-domain-name-only/70574/1 "2017-09-22T13:39:33Z")

</div>

Hi everyone. So I have setup Discourse and configure Cloudflare and SSL connection.  
So far so good. Now I see my website is accessible via the domain name and the default ip, which I do not want.

When I use a CMS such as Wordpress or Modx ( on apache ), I normally configure the ht.access to do the trick. But Discourse is not on Apache…

Is there a way to do that with Nginx ? I am not even sure that Discourse uses it.

Anyway that is the code I would be using:

```
# Tells the browser to always force SSL.
# Do not use this line if there is a chance you will turn off SSL

add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";

if ($scheme != "https") {
	rewrite ^ https://discourse.mydomain.com$request_uri permanent;
}
if ($host != "discourse.mydomain.com") {
	rewrite ^ https://discourse.mydomain.com$request_uri permanent;
}

```

Any suggestions ?

Thanks

---

_[View the full topic](https://meta.discourse.org/t/forcing-access-to-discourse-via-domain-name-only/70574)._
