Discourse のデフォルトポートを変更する方法

本菜鸡之前自己也建了一个 Discourse 论坛,但是由于 Discourse 本身官网要求强制 Docker 部署,而且容器内部自带 Nginx,而且绑定了 80 和 443 端口,导致如果我想要在同一台机器上部署其他网站或者同时运行

恰好在论坛看见站长 @anonymous_coward_old 发的技术细节,于是本菜鸡很好奇这个方法是如何实现的:

「いいね!」 1

其实就是想知道反代是怎么实现的啦~
困扰挺久的其实 :innocent:

The account you pinged is a public anonymous account

@anonymous_coward

「いいね!」 1

Change the container definition

This is where we change how Discourse actually gets set up. We don’t want the container listening on ports - instead, we’ll tell it to listen on a special file.

You need to edit /var/discourse/containers/app.yml to disable ssl and add template to create nginx sock. It should look like this:

# base templates used; can cut down to include less functionality per container templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  # - "templates/web.ssl.template.yml" # remove - https will be handled by outer nginx
  # - "templates/web.letsencrypt.ssl.template.yml" # remove -- https will be handled by outer nginx
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"  # <-- Added

Be sure to remove or comment out the exposed ports by putting a # in front.

# which ports to expose?
# expose: comment out entire section by putting a # in front of each line
# - "80:80"   # http
# - "443:443" # https

Now you can

/var/discourse/launcher rebuild app

to rebuild Discourse to make its data available to the socket.

容器里头的 nginx 监听在 unix socket,共享到容器外,用你喜欢的反代代理即可,如 caddy:

    reverse_proxy unix//var/discourse/shared/app/nginx.http.sock
「いいね!」 2

谢谢佬 by the way 想知道你服务器是哪里买的

这个全方位好,除了 CN net

€13.68/m 8C16G+512G, unlimited BW, dedicated CPU


这个香港的有时候网络好
https://hosthatch.com/

$15/m 4C16G(1 dedicated CPU+3 shared CPU), ~4T BW

「いいね!」 1

感谢分享 我用了某杂牌(狗云) :melting_face:
有机会换过来

杂牌厂不能用(尤其是国人商家、one man)
Hetzner Netcup(Anexia) Vultr DO Linode AWS/Lightsail Oracle(如果你的信用卡能注册的上) Azure/GCP(如果你有钱) 正规大厂随便用(这些我都用过)

我原先用的是 Digital Ocean 学生包里面的
但是后来考虑到需要长期维护 学生包的钱只能用一年所以想迁移
现在既然这样考虑去办一张 visa 卡了
其实我昨天买了雨云的香港 CN2 优化机器 但是被恶心了(封了 587 端口 邮箱服务器没法用

感觉反代服务器是不是可以“飘一点” :smiling_imp:

如果业务不重要可以。不靠谱的反代机器会:

  • 降低 uptime
  • 有数据泄露的风险(man in the middle)

感谢提醒,不过我还想再问一下人在国内你的支付方法是什么:

  • 信用卡
  • palpay
    大学生怎么办卡 :melting_face:

去 BOC 陕西省分行办理“长城跨境通”借记卡(debit card)(Mastercard)

All right. Thanks a lot.

Do not use domestic foreign‑currency debit cards; you have to constantly purchase foreign exchange manually, which is cumbersome, and the FX controls are annoying.

The suggestion is: if you can, open an account in Hong Kong and get an HSBC MasterCard debit card.

If you can’t, you can get an American Express Lucky debit card from Guangfa Bank. This card is a RMB card; all domestic and overseas transactions (including those in mainland China) are settled in RMB. Moreover, if you have no other cards with Guangfa, this card can open a Tier‑1 account.

「いいね!」 3

确实有想去香港开一张卡的想法 国内的各种外汇卡让我很迷 :melting_face:
不知道香港开卡有没有什么要求 准备明年寒假去一趟香港 顺便办一张电话卡

对了老哥,借记卡信用卡储蓄卡这三种卡有啥关系和区别吗

Why is it bro :pleading_face::cry: zisha? :hugging_face_pleading_face:

「いいね!」 2

小哥哥 小姐姐 :face_holding_back_tears:
教教小弟弟 好么 :confounded:

「いいね!」 1

:door:Friend, I want to ask what plugin or theme component the signature or “little tail” on this site is. I really like it.

「いいね!」 1