OAuth2 redirect_uri 使用 HTTP,而我的论坛使用 HTTPS

你好,

我刚刚在我的 Discourse 论坛上启用了 HTTPS(在主机系统上使用 Let’s Encrypt + nginx)。未添加重定向,因此访问者可以使用 HTTP 或 HTTPS。一切运行正常。

随后,我尝试启用 Google Oauth2 认证。但我注意到,Discourse 在调用 Google Oauth2 时,将 redirect_uri 设置为 HTTP 论坛 URL,而论坛实际上是通过 HTTPS 打开的。

我该如何解决这个问题?我的论坛地址是 https://discussion.listary.com/ 。提前感谢任何帮助。

Do You have force https enabled?

1 个赞

No. Is there a Discourse setting for that?

Indeed there is!

In admin > settings
Search for force https and enable it.

2 个赞

Just tried that setting. And unfortunately, it’s still the same.

I think Discourse should be able to detect the original protocol automatically. I don’t know why it doesn’t work in my case.

I got it working. I used Certbot to manage Let’s Encrypt on my host system. It turned out that some rules Certbot added to the nginx config file is not fully compaitible with Discourse docker. I fixed it according to Running other websites on the same machine as Discourse.

3 个赞