(已取代)将其他域名重定向到您的Discourse实例

Update DNS Record

Update the A record for the domain(s) you want to redirect to original domain.

It helped and so am sharing. If somebody trying to change the A Record for the route domain. Don’t use * in the hostname but @ in the hostname of Digitalocean DNS management.

Why are you using digital ocean for DNS? It would be out recommendation to stick with your registrar’s DNS unless you’re looking to use specific features which require moving, such as Cloudflare or Route 53.

Not sure what’s the disadvantage of that. But the reason why i do it is using the registrar only for buying domain and leave that alone. Then manage everything in DO. Also their interface looks easy to manage multiple domains and setup.

Here’s my issue:

If I redirect my naked domain example.com -> www.example.com using the instructions here, I have problems with my ssl certificate not being valid when going to example.com.

If I use NakedSSL to redirect example.com -> www.example.com. My cookies and therefore topics read seems to not display accurately.

What is the solution? I am using a docker install on digital ocean.

@techAPJ @codinghorror

You must redirect to the “correct” form that you have certs for. Content cannot be at multiple domains simultaneously, that is a configuration error, and Google will ding you for duplicate content.

2 个赞

Ok. I did get it working using the instructions as above. As you said my certificate probably hadn’t completely switched from the naked domain to the www domain.

However, I still have issues with discourse not remembering what I have read when I return to the root of the site. If I go straight to the root, all messages are shown as unread until I follow the latest and top links. Any idea what may be causing this behaviour?

Can someone please confirm these settings for me?

    - file:
        path: /etc/nginx/conf.d/www_redirect_1.conf
        contents: |
          server {
            listen 80;
            listen 443 ssl;
            server_name www.reddcointalk.org;
            return 301 https://reddcointalk.org$request_uri;
          }

The goal here is to redirect https://www.reddcointalk.org AND http://www.reddcointalk.org to https://reddcointalk.org. However, https://www.reddcointalk.org provides an SSL error. I’ve tried several different configurations of this but end up in the same place.

1 个赞

I suppose it works fine for you now; as the links mentioned are redirecting fine. I suppose you had to specify ssl_certificate and ssl_certificate_key. Can you please share your updated settings?

I wanted the visitors of hotelbobbygg.xyz be forwarded to already working https://a.hotelbobbygg.xyz.

I’ve did exactly as you told. (app.yml shown below) and then rebuilt the image.

But visitors of hotelbobbygg.xyz get the certificate error (and can’t add exception either). I’ve even tried incognito mode.

I was wondering, in the path line (i.e. the line just next to ‘-file’), do I only need to give some name such as ‘some_name.conf’ or do I need to create that same named file ‘some_name.conf’ somewhere, under some /etc/path?

This is a great start. So, the problem I’m running into here is that since the root domains (www and non-www) do not have SSL certs assigned to them by Let’s Encrypt in the docker container build we get an HTTPS error from the browser before the redirect even happens. Right? How do we add SSL to the root domains (www and non-www) so that this redirect will actually work?

Check out Setting up Let’s Encrypt with Multiple Domains. I used this yesterday to have the www.example.com site that I set up properly redirect https://example.com and it worked as expected.

2 个赞

此内容在 2021 年是否仍然有效?我想将一个旧网址重定向到我的新主机,但我的 discourse 设置是一个 https:// 网站。看起来这里的说明是针对 http:// 网站(端口 80?)的。
有人能好心展示重定向所需的步骤吗:
https://discourse.oldsite.com
https://discourse.newsite.com

我使用的是 DO,我猜我还需要在我网络设置中添加一个 CNAME 记录,将旧站点指向新站点?
我还需要对 LetsEncrypt 做些什么吗?
感谢您的帮助!

链接的主题应该可以工作。它解释了如何向 app.yml 添加一些内容,这些内容将导致 let’s encrypt 为两个子域获取证书。是的,您需要使用 CNAME 或以其他方式让两个域解析到您的 droplet。

1 个赞

非常感谢您的快速回复。
所以,我只需要执行您之前帖子中详细介绍的步骤(使用 Let’s Encrypt 设置多个域),而不需要执行 OP 的内容?(OP 只提到了端口 80)

是的。我相当确定,只有 Set up Let’s Encrypt with multiple domains / redirects 中的那一个。

首先确保 DNS 正确,否则您将达到速率限制。

3 个赞

我将此块添加到我的 app.yml 中

after_web_config:
  - replace:
      filename: /etc/nginx/nginx.conf
      from: /sendfile.+on;/
      to: |
        server_names_hash_bucket_size 64;
        sendfile on;
  - file:
      path: /etc/nginx/conf.d/discourse_redirect_1.conf
      contents: |
        server {
          listen 80;
          server_name mydomain.tld2;
          return 301 $scheme://mydomain.tld1$request_uri;
        }
after_ssl:
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--keylength/
        to: "-d mydomain.tld2 -d mydomain.tld2 --keylength"

我当前的域名是 mydomain.tld1,重建后,mydomain.tld1 可以正常工作,但当我尝试访问 mydomain.tld2 时,它显示 ERR_CERT_COMMON_NAME_INVALID,反之亦然(在 .yml 文件中切换 tld1 和 tld2)。

我是否遗漏了某些配置?

1 个赞

我认为 Let’s Encrypt 模板中有些东西发生了变化,并且需要其他东西,但我还没有花时间完全调试它。

我在 Digital Ocean 上设置了一个 Discourse 实例,地址是 forum.mysite.ca。我想将 mysite.ca 指向 forum.mysite.ca,并且我认为我已经成功了,但是当我访问 mysite.ca 时,会出现以下警告消息:

“您的连接不安全

攻击者可能试图窃取您在 mysite.ca 上的信息(例如密码、消息或信用卡)。了解详情

NET::ERR_CERT_COMMON_NAME_INVALID”

还有一个“高级”按钮,其中包含一个文本链接,写着“继续前往 mysite.ca(不安全)”。

我找了一周的答案了,遇到了很多麻烦。任何建议或链接都会有帮助。

mysite.ca 有自己的证书吗?

我按照这个 discourse/docs/INSTALL-cloud.md at main · discourse/discourse (github.com) 的说明操作了,我认为我没有为我的 mysite.ca 设置证书。