# Website does not forward to https

**URL:** https://meta.discourse.org/t/website-does-not-forward-to-https/143707
**Category:** Self-hosting
**Created:** [March 9, 2020, 4:10pm UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707 "2020-03-09T16:10:39Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![pr0cesor](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@pr0cesor](https://meta.discourse.org/u/pr0cesor)
#### Post date: [March 9, 2020, 4:10pm UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/1 "2020-03-09T16:10:40Z")

</div>

Hi there,

When I type for example “[thenameofmywebsite.com](http://thenameofmywebsite.com)” in the browser, it does not forward automatically to secure SSL https.

Where can I change this for discourse? Thank you.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [March 9, 2020, 4:18pm UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/2 "2020-03-09T16:18:28Z")

</div>

> [@pr0cesor](#):
>
> Where can I change this for discord? Thank you.

Discord is a different product, I’m assuming you mean Discourse.

How did you configure SSL? How was this instance installed?

If you followed the standard guide then HTTPS redirection works as standard, which suggests that you either installed via a different method, or changed the configuration after installation.

---

<div class="post-metadata">

### Author: ![pr0cesor](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@pr0cesor](https://meta.discourse.org/u/pr0cesor)
#### Post date: [March 11, 2020, 10:07am UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/3 "2020-03-11T10:07:45Z")

</div>

Sorry, typo.

Here is my discourse.conf

```
server {

    if ($host = wolcengame.net) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    listen [::]:80;
    server_name wolcengame.net www.wolcengame.net; 
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name wolcengame.net www.wolcengame.net;

```

So there is a difference between [https://wolcengame.net](https://wolcengame.net) and [www.wolcengame.net](http://www.wolcengame.net) . The first link works and load the page, however when clicking on the second it turns into [https://www.wolcengame.net](https://www.wolcengame.net) and dark screen, nothing is loading.

I have no idea what is wrong and how to fix this.

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [March 11, 2020, 11:35am UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/4 "2020-03-11T11:35:02Z")

</div>

> [@pr0cesor](#):
>
> if ($host = [wolcengame.net](http://wolcengame.net)) { return 301 https://$host$request\_uri; } # managed by Certbot

Remove this part then restart nginx and it should work fine.

---

<div class="post-metadata">

### Author: ![pr0cesor](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@pr0cesor](https://meta.discourse.org/u/pr0cesor)
#### Post date: [March 11, 2020, 9:40pm UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/5 "2020-03-11T21:40:08Z")

</div>

> [@itsbhanusharma](#):
>
> Remove this part then restart nginx and it should work fine.

I don’t think anything changed. The issue is still there. Any other idea?

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [March 12, 2020, 1:16am UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/6 "2020-03-12T01:16:42Z")

</div>

That config can be changed in many ways.

1. Only set https redirect to the domain You prefer
2. Set a redirect from non-www to www (or vice versa)
3. Make sure You have correct discourse hostname in yml file

---

<div class="post-metadata">

### Author: ![pr0cesor](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@pr0cesor](https://meta.discourse.org/u/pr0cesor)
#### Post date: [March 12, 2020, 9:25am UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/7 "2020-03-12T09:25:55Z")

</div>

Hi Bhanu.

1. https is set for my domain (as you already noticed from the provided links to my website)
2. Redirection is set from www to non-www as you already noticed from the code that I provided
3. The discourse hostname in yml file is correct as you noticed that my website is up and running.

> DISCOURSE\_HOSTNAME: [wolcengame.net](http://wolcengame.net)

I have another website with the same configuration as my discourse.conf, and there is no similar issue like this one there.

My question is, is there something from discourse that is interfering with the nginx redirection? I tried everything yesterday and I run out of idea to solve this issue.

This is my second website [www.koktailmolotov.com](http://www.koktailmolotov.com) . As you see if you click on the website, it redirects automatically to the format [https://koktailmolotov.com](https://koktailmolotov.com). The conf settings are the same as for my discourse website.

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [March 12, 2020, 9:39am UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/8 "2020-03-12T09:39:57Z")

</div>

> [@pr0cesor](#):
>
> My question is, is there something from discourse that is interfering with the nginx redirection?

That’s not possible since all the traffic is handled by external nginx. I’m assuming here that You’re running discourse in socketed template and the external nginx proxy is handling all the traffic.

If You can post nginx configuration for discourse, I may be able to help you figure out the issue.

---

<div class="post-metadata">

### Author: ![pr0cesor](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@pr0cesor](https://meta.discourse.org/u/pr0cesor)
#### Post date: [March 12, 2020, 9:49am UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/9 "2020-03-12T09:49:04Z")

</div>

> [@itsbhanusharma](#):
>
> If You can post nginx configuration for discourse, I may be able to help you figure out the issue.

Below the entire discourse.conf nginx configuration as for today:

> server {
> 
> ```
> listen 80;
> listen [::]:80;
> server_name www.wolcengame.net;
> return 301 $scheme://wolcengame.net$request_uri;
> 
> ```
> 
> }
> 
> server {
> 
> ```
> listen 443 ssl http2;
> listen [::]:443 ssl http2;
> server_name wolcengame.net www.wolcengame.net;
> 
> ssl on;
> ssl_certificate /etc/letsencrypt/live/wolcengame.net/fullchain.pem; # managed by Certbot
> ssl_certificate_key /etc/letsencrypt/live/wolcengame.net/privkey.pem; # managed by Certbot
> ssl_dhparam /etc/letsencrypt/live/wolcengame.net/dhparams.pem;
> include /etc/nginx/snippets/ssl.conf;
> 
> http2_idle_timeout 5m; # up from 3m default
> 
> location / {
> proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;
> proxy_set_header Host $http_host;
> proxy_http_version 1.1;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header X-Forwarded-Proto https;
> proxy_set_header X-Real-IP $remote_addr;
> 
> }
> 
> ```
> 
> }

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [March 12, 2020, 10:25am UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/10 "2020-03-12T10:25:21Z")

</div>

> [@pr0cesor](#):
>
> return 301 $scheme://wolcengame.net$request\_uri;

Change this to

```plaintext
return 301 https://wolcengame.net$request_uri;

```

> [@pr0cesor](#):
>
> listen 443 ssl http2; listen [::]:443 ssl http2; server\_name [wolcengame.net](http://wolcengame.net) [www.wolcengame.net](http://www.wolcengame.net);

Remove `www.wolcengame.net` from this

and create a separate block like

```plaintext
listen 443 ssl;
listen [::]:443 ssl;
server_name www.wolcengame.net;
ssl_certificate /etc/letsencrypt/live/wolcengame.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/wolcengame.net/privkey.pem; 
return 301 https://wolcengame.net$request_uri;

```

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [March 12, 2020, 12:06pm UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/11 "2020-03-12T12:06:10Z")

</div>

> [@pr0cesor](#):
>
> is there something from discourse that is interfering with the nginx redirection?

To be clear this isn’t a discourse issue at all.

Discourse can only operate under one FQDN. The issue is that you had configured two and hadn’t configured your redirects correctly. The solutions to both of these problems were already answered in other topics.

---

<div class="post-metadata">

### Author: ![pr0cesor](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@pr0cesor](https://meta.discourse.org/u/pr0cesor)
#### Post date: [March 12, 2020, 12:46pm UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/12 "2020-03-12T12:46:31Z")

</div>

> [@itsbhanusharma](#):
>
> and create a separate block like

You are genius, this fixed the issue. Thank you very much

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [August 19, 2023, 11:15am UTC](https://meta.discourse.org/t/website-does-not-forward-to-https/143707/13 "2023-08-19T11:15:23Z")

</div>

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